I have a Lucene index where (when using Luke) the data seems ok.
When i try to query the index i don't get the expected results.
In my Lucene index i have a series of fields - for example firstname that contains the name 'Dennis' - but when i query the index it returns nothing. In another firstname field i have 'Hanne' - if my search phrase is 'Hanne' it returns nothing - but if it is 'Anne' the name is found.
I have made a stripped down version of what I am doing. I am using the WhiteSpaceAnalyzer in both my indexer and my searcher.
Can you debug and to searchCriteria.ToString() this will give you the generated query and paste that back. Also any reason for using whitespace analyser and not standard one. If i remember rightly whitespace one is case sensitive? Also why are doing string term = "*" + searchText.ToString() + "*"; the multiple wildcard statement will tag on wildcard at end.
Ismail - you pointed me in the right direction. I ended up changing the analyzer to the StandardAnalyzer - and then I removed the standard stop words list by replacing it with an empty on.
Examine / Lucene does return the expected results
I have a Lucene index where (when using Luke) the data seems ok.
When i try to query the index i don't get the expected results.
In my Lucene index i have a series of fields - for example firstname that contains the name 'Dennis' - but when i query the index it returns nothing. In another firstname field i have 'Hanne' - if my search phrase is 'Hanne' it returns nothing - but if it is 'Anne' the name is found.
I have made a stripped down version of what I am doing. I am using the WhiteSpaceAnalyzer in both my indexer and my searcher.
Code:
string[] _internalFieldsToSearch = new[] { "company", "department", "description", "firstname", "jobTitle", "lastname", "mobileNumber", "workArea", "email", "memberPositions" };
string searchText = searchStr.Trim();
while (searchText.IndexOf('*') == 0 || searchText.IndexOf('?') == 0 || searchText.IndexOf('.') == 0)
{
searchText = searchText.Remove(0, 1);
}
if (searchText.Length > 0)
{
string[] searchTerms = searchText.Split(' ').ToArray();
BaseSearchProvider searcher = ExamineManager.Instance.SearchProviderCollection["InternalEUCMemberSearcher"];
ISearchCriteria searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
string term = "*" + searchText.ToString() + "*";
IBooleanOperation queryFiltered = searchCriteria.GroupedOr(_internalFieldsToSearch, term.ToLower().MultipleCharacterWildcard());
ISearchResults searchResults = searcher.Search(queryFiltered.Compile());
}
Have you tired to do the search in the back office of umbraco?
Developer > Examine tab
then select your searcher from the list, then type in your search term
Hi again,
Unfortunately the solution is running on 4.11.1 - so i cannot do that. Thanks for the input though.
ST
Sonni,
Can you debug and to searchCriteria.ToString() this will give you the generated query and paste that back. Also any reason for using whitespace analyser and not standard one. If i remember rightly whitespace one is case sensitive? Also why are doing string term = "*" + searchText.ToString() + "*"; the multiple wildcard statement will tag on wildcard at end.
Regards
Ismail
Hi Ismail,
Better late than never (to post a reply) :-)
Ismail - you pointed me in the right direction. I ended up changing the analyzer to the StandardAnalyzer - and then I removed the standard stop words list by replacing it with an empty on.
That did the trick. Thank you for your input!
Sonni T.
Sonni,
Awesome, dont forget to mark post as solution will help others.
Regards
Ismail
is working on a reply...