above is my code. I'm trying to search the nodeName & bodyText for each word in the inputted searchterm. Though it seems Examine only searches the first word i enter. I saw a similar topic with this but the only difference i saw was the way he split his SearchTerm. Tried quite some stuff already, hopefully you can give me some directions.
SearchResults = ExamineManager.Instance.SearchProviderCollection["DemoSearcher"].Search(criteria.RawQuery("(nodeName:\"then\" OR bodyText:\"then\") OR (nodeName:\"go further\" OR bodyText:\"go further\") OR (nodeName:\"go\" OR bodyText:\"go\")"));
temporarily solution for me, thought i would like the solution by using the IQuery stuff.
Examine search every word
<code>
var criteria = ExamineManager.Instance
.SearchProviderCollection["DemoSearcher"]
.CreateSearchCriteria();
string[] sSearchTerm = SearchTerm.Split(' ');
Examine.SearchCriteria.IBooleanOperation filter = null;
for(int i = 0;i<sSearchTerm.Length;i++)
{
if(i==0){
filter = criteria.GroupedOr(new string[] { "nodeName", "bodyText" }, sSearchTerm[i])
.Not().Field("umbracoNaviHide", "1");
}else{
filter = filter.Or().GroupedOr(new string[] { "nodeName", "bodyText" }, sSearchTerm[i]);
}
}
SearchResults =
ExamineManager.Instance.SearchProviderCollection["DemoSearcher"].Search(filter.Compile());
</code>
Hi,
above is my code. I'm trying to search the nodeName & bodyText for each word in the inputted searchterm. Though it seems Examine only searches the first word i enter. I saw a similar topic with this but the only difference i saw was the way he split his SearchTerm. Tried quite some stuff already, hopefully you can give me some directions.
greetings,
Jonas
temporarily solution for me, thought i would like the solution by using the IQuery stuff.
If you do a ToString on the compiled filter what is the output?
{ SearchIndexType: , LuceneQuery: +(nodeName:go bodyText:go) -umbracoNaviHide:1 (nodeName:further bodyText:further) }
The problem is that the 2nd query you're adding is added as an OR, but because the first one is an AND it will always take precidence.
Check out the blog I did here: http://farmcode.org/post/2010/08/12/How-to-build-a-search-query-in-Examine.aspx it explains how queries are built in Examine.
is working on a reply...