Ismail - thanks for the reply. May have found the problem in that my query was returning nothing as the fieldnames were different .
Once i tidy up my code i will post a code snippet here for others.
Using your code from the hour course from last years UmbracoFestival - cheers
Scott I just ran into the same issue. What did you mean when you said you field names were not the same? How did you solve this issue of getting no results with the MultiIndexSearcher?
Using Umbraco 7.5.1.1.
Did something recently change in Examine when it comes to multi indexing? I currently have the following setup in my ExaminSettings.config ...
I would firstly check in Examine manager in Backoffice Devlopment section that the 2 index are upto date - rebuild them if necessary.
What is your razor code?
My issue was i was searching for different fields.
eg Content and External Index (they had different fields) so i used a Examine Event to create a common field which combined the fields together..
("combinedFields")
and used that in the Examine query:
e.g.
examineQuery = criteria.Field("combinedFields"), searchTerm)
Yes my 2 indexes are up-to-date. My Alphaindexer and Mediaindexer look good. I clicked the "Rebuild Index" button for both of them. On the same page, under "Seachers" I can go to AlphaSearcher and MediaSearcher, and use their search tool to search for results. But the moment I use MultiIndexSearcher, I get 0 results.
On my ExaminIndex.config file, my indexes look like this...
<!-- Indexset for Alpha Documents-->
<IndexSet SetName="AlphaIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Alpha">
<!--the standard properties-->
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName" />
<add Name="updateDate" />
<add Name="writerName" />
<add Name="path" />
<add Name="nodeTypeAlias" />
<add Name="parentID" />
</IndexAttributeFields>
<!--the document type properties we created - use exact alias-->
<IndexUserFields>
<add Name="alpha summary"/>
<add Name="alpha description"/>
</IndexUserFields>
<!--confine to nodes of document type Alpha-->
<IncludeNodeTypes>
<add Name="alpha"/>
</IncludeNodeTypes>
</IndexSet>
<!--using the CogUmbracoExamineMediaIndexer-->
<IndexSet SetName="MediaIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/MediaIndexSet">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName" />
<add Name="updateDate" />
<add Name="writerName" />
<add Name="path" />
<add Name="nodeTypeAlias" />
<add Name="parentID" />
</IndexAttributeFields>
<!--the doc type properties we created - use the property alias-->
<IndexUserFields>
<add Name="friendlyFileName"/>
</IndexUserFields>
</IndexSet>
You mentioned...
I used a Examine Event to create a common field which combined the
fields together.. ("combinedFields")
Where & How can I learn to do that? How is that different from this tutorial?
Just sharing code. I finally got something reeeaal basic to work
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Web.Mvc.Html
@using Umbraco.Web
@using UmbracoExamine
@using Examine.SearchCriteria;
@using Examine.LuceneEngine.SearchCriteria;
@using Examine.LuceneEngine;
@using Examine.LuceneEngine.Providers;
@{
Layout = "alpha.cshtml";
string term = Request["Query"];
}
<strong>Search for:</strong> @term<br />
<ul>
@{
//container for the searcher
Examine.Providers.BaseSearchProvider searcher = null;
//container for the results
ISearchResults searchResults;
//my desired searcher
searcher = ExamineManager.Instance.SearchProviderCollection["MultiIndexSearcher"];
if (term == null)
{
<p>no query set yet</p>
}
else
{
//create search criteria
var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
//the criteria our search term as a raw query
var query = searchCriteria.RawQuery(term);
//action a search based on our query
searchResults = searcher.Search(query);
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["friendlyName"]</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>
This works for me and I feel this is a good starting point for me to grow from. I need more references to take this to the next level.
Examine MultiIndexSearcher Example
Hi,
Trying to get a searcher in razor using the MultiIndexSearcher provider.
This results in zero results.
Does anyone have an example or code snippet for using the MultiIndexSearcher as I am clearly missing something.
Thanks
Scott,
That looks fine to me. Can you write out the generated lucene query and then test that query on both indexes.
Regards
Ismail
Ismail - thanks for the reply. May have found the problem in that my query was returning nothing as the fieldnames were different . Once i tidy up my code i will post a code snippet here for others.
Using your code from the hour course from last years UmbracoFestival - cheers
Scott I just ran into the same issue. What did you mean when you said you field names were not the same? How did you solve this issue of getting no results with the MultiIndexSearcher?
Thanks
Using Umbraco 7.5.1.1. Did something recently change in Examine when it comes to multi indexing? I currently have the following setup in my ExaminSettings.config ...
But no matter what, I always get 0 results displayed when using the search tool.
That will work.
I would firstly check in Examine manager in Backoffice Devlopment section that the 2 index are upto date - rebuild them if necessary.
What is your razor code?
My issue was i was searching for different fields. eg Content and External Index (they had different fields) so i used a Examine Event to create a common field which combined the fields together.. ("combinedFields")
and used that in the Examine query: e.g. examineQuery = criteria.Field("combinedFields"), searchTerm)
Yes my 2 indexes are up-to-date. My Alphaindexer and Mediaindexer look good. I clicked the "Rebuild Index" button for both of them. On the same page, under "Seachers" I can go to AlphaSearcher and MediaSearcher, and use their search tool to search for results. But the moment I use MultiIndexSearcher, I get 0 results.
On my ExaminIndex.config file, my indexes look like this...
You mentioned...
Where & How can I learn to do that? How is that different from this tutorial?
Thanks for the help!
Do you mean in the Examine Management in Developer section?
"..But the moment I use MultiIndexSearcher, I get 0 results."
If so this doesn't work for MultiIndexSearcher
ahhh that's probably my problem! back to testing...
I have code i can share - will get it in a fit state over weekend.
Just sharing code. I finally got something reeeaal basic to work
This works for me and I feel this is a good starting point for me to grow from. I need more references to take this to the next level.
Thanks for helping me think / walk through this!
Hi,
i have a sample umbraco site with some code concepts for basic searching. It is by no means perfect code - but does have some useful code.
https://bitbucket.org/sleslie/umbraco-multisearcher-demo
S>
is working on a reply...