I'm getting on very well with Examine now, and using the fluentAPI system (nice work Shannon).
I seem to be getting different results depending whether or not I query the index using examine or use the Java Applet Luke.
For example
"+((nodeName:chris sauls*)) +__IndexType:content" using examine in debug mode through VS brings back zero results, but if I do the same query on the same index using Luke I get 2 results.
I've set the default Boolean operation to be "Or". I don't think there is any other logic in my code to interfere with the results - here's a simplified version of my code with only one query...
var criteria2 = m_Searcher.CreateSearchCriteria(IndexTypes.Content, Examine.SearchCriteria.BooleanOperation.Or);
As I was writing this answer though I realised that it was a bit silly to have to pass 'string.Empty' in, so I fixed it. The latest check in allows you to do this:
And you don't need to specify the default boolean operation, in fact if you look at your compiled search query this actually doesn't do anything for you. This query:
+((nodeName:..)) +__IndexType:...
Is treated the same by lucene as this:
+(+(nodeName:...)) +__IndexType:...
The reason for using a default boolean operation that is not AND is if you wanted something like this:
Although that example is something that's is a real fringe-case, that's what it's for, when you want multiple conditions grouped together and none of them being a 'master' condition. Here you'd be wanting either the nodeName to have Hello and of type someDocType OR nodeName to have World and of type someOtherDocType.
If you didn't change the default boolean operation the first group would always have to match.
Examine results doesn't match what Luke says
Hi all,
I'm getting on very well with Examine now, and using the fluentAPI system (nice work Shannon).
I seem to be getting different results depending whether or not I query the index using examine or use the Java Applet Luke.
For example
"+((nodeName:chris sauls*)) +__IndexType:content" using examine in debug mode through VS brings back zero results, but if I do the same query on the same index using Luke I get 2 results.
I've set the default Boolean operation to be "Or". I don't think there is any other logic in my code to interfere with the results - here's a simplified version of my code with only one query...
var criteria2 = m_Searcher.CreateSearchCriteria(IndexTypes.Content, Examine.SearchCriteria.BooleanOperation.Or);
var filter2 = criteria2.GroupedOr(
new string[]
{ "nodeName" },
new IExamineValue[]
{ queryText.MultipleCharacterWildcard() }
).Compile();
ISearchResults searchResults = m_Searcher.Search(filter2);
Is there an extra option I have to set or is Luke just a better searcher?
Many thanks
Neil
Luke allows you to specify a default field when doing a search, something which Examine doesn't allow.
I think the problem is that your not escaping your search term before passing it into Examine, this part:
That will search on the NodeName of 'chris' and a default field of 'sauls*', and I have no idea what the default field will be interpreted as.
To do an Escape and then a MultipleCharacterWildcard you'll need this:
As I was writing this answer though I realised that it was a bit silly to have to pass 'string.Empty' in, so I fixed it. The latest check in allows you to do this:
Should make it a bit simpler ;).
And you don't need to specify the default boolean operation, in fact if you look at your compiled search query this actually doesn't do anything for you. This query:
Is treated the same by lucene as this:
The reason for using a default boolean operation that is not AND is if you wanted something like this:
Although that example is something that's is a real fringe-case, that's what it's for, when you want multiple conditions grouped together and none of them being a 'master' condition.
Here you'd be wanting either the nodeName to have Hello and of type someDocType OR nodeName to have World and of type someOtherDocType.
If you didn't change the default boolean operation the first group would always have to match.
Hmm... maybe I should blog this now :P
Hi Slace - thanks for the update - it was very helpful. If you do blog it - could you change the search name used please (;
(For future reference here's the blog post: http://farmcode.org/post/2010/08/12/How-to-build-a-search-query-in-Examine.aspx )
What do you mean by the search name?
is working on a reply...