The ExternalIndexSet and the MediaIndexSet referred to are the out-of-box set and the media set inserted when I installed the ExamineFileIndexer package, respectively.
Here's code from my test page:
@using Examine.SearchCriteria
@using Examine
@{
Layout = null;
string term = "control";
// Get a searcher
Examine.Providers.BaseSearchProvider searcher = ExamineManager.Instance.SearchProviderCollection["MultiIndexSearcher"];
// Create search criteria instance
ISearchCriteria searchCriteria = searcher.CreateSearchCriteria();
// Pass the search criteria instance our search term as a raw query
ISearchCriteria query = searchCriteria.RawQuery(term);
// Search using the criteria in our query. Receive results.
ISearchResults searchResults = searcher.Search(query);
}
<ul>
@foreach (var searchResult in searchResults)
{
if (searchResult.Fields["nodeTypeAlias"].ToString().ToLower() == "file")
{
//we have found a physical file in the media folder structure
//note that this is the line where we can capitalise on that Media File custom property we created - friendlyFileName
var media = Umbraco.Media(searchResult.Id);
<li>
<a href="@media.Url" target="_blank">@searchResult.Fields["nodeName"]</a>
</li>
}
else
{
//we are a content type other than a file
<li>
<a href="@Umbraco.NiceUrl(searchResult.Id)">@searchResult.Fields["nodeName"]</a>
</li>
}
}
</ul>
In my database, there are two .pdf files and two document types with the word "control" in them.
When I use the MultiIndexSearcher, I get six results: one each for the doc types, and two each for the files (duplicates, in other words).
When I use the MediaIndexSearcher, I get two results -- one for each file. Also, if I remove the ExternalIndexSet from the MultiIndexSearcher, I get the proper number of results (one for each file).
I know I could, of course, query the indexes separately and combine the results. I'd rather figure out how to make the MultiIndexSearcher work, though. Any help would be appreciated!
Cogworks.ExamineFileIndexer duplicate results with MultiIndexSearcher
With ExamineFileIndexer, I get duplicate results when:
I do not get duplicate results when the same term is found in two document types.
Here's the element I added for the searcher:
The ExternalIndexSet and the MediaIndexSet referred to are the out-of-box set and the media set inserted when I installed the ExamineFileIndexer package, respectively.
Here's code from my test page:
In my database, there are two .pdf files and two document types with the word "control" in them.
When I use the MultiIndexSearcher, I get six results: one each for the doc types, and two each for the files (duplicates, in other words).
When I use the MediaIndexSearcher, I get two results -- one for each file. Also, if I remove the ExternalIndexSet from the MultiIndexSearcher, I get the proper number of results (one for each file).
I know I could, of course, query the indexes separately and combine the results. I'd rather figure out how to make the MultiIndexSearcher work, though. Any help would be appreciated!
is working on a reply...