I'm creating a simple Lucene search module for one of my websites. I first watched the umbraco.tv episodes to get it all in my head.
So I first copied the example from umbraco.tv to start. created a demoindex, checked it through luke. Everything worked. Created the usercontrol, did a search. It worked...but then I ran into something strange:
when I search for 'word' (without quotes of course) it does not find 'largerword'. Using * doesn't seem to help in this, and I cannot seem to find the problem.
Anyone have experience with Examine and know what this is about?
In you query code you need to ensure you do wild card query this is done by
var criteria = searcher.CreateSearchCriteria();
IBooleanOperation query = criteria.Field("contents",searchQuery.MultipleCharacterWildcard());
the MultipleCharacterWildCard() is an extension method on strings and is part of the examine library. That will when query is compile tag the * wildcard character giving you a wildcard query.
But putting the * before the word doesnt work. So now I can search ' larger* ' and find 'largerword'. But I cannot search ' *word ' and find 'largerword'
the MultipleSearchCriteria extension is hidden somewhere deeper within the examine namespace, because otherwise the string extension would pop up everywhere.
I think you only have to add:
using UmbracoExamine.SearchCriteria.LuceneSearchExtensions
Umbraco Examine and Wildcardsearching
Hi,
I'm creating a simple Lucene search module for one of my websites. I first watched the umbraco.tv episodes to get it all in my head.
So I first copied the example from umbraco.tv to start. created a demoindex, checked it through luke. Everything worked. Created the usercontrol, did a search. It worked...but then I ran into something strange:
when I search for 'word' (without quotes of course) it does not find 'largerword'. Using * doesn't seem to help in this, and I cannot seem to find the problem.
Anyone have experience with Examine and know what this is about?
thanks
Martin
Martin,
In you query code you need to ensure you do wild card query this is done by
the MultipleCharacterWildCard() is an extension method on strings and is part of the examine library. That will when query is compile tag the * wildcard character giving you a wildcard query.
Regards
Ismail
Hi Ismail,
thanks for replying that quickly. I'm trying it out, but maybe I'm missing something:
SearchTerm.MultipleCharacterWildCard() doesnt work with me because SearchTerm is a protected string SearchTerm { get; private set; }
Do I need to include a reference to the extensionlibrary? It should be a string right? Not a IExamineValue?
martin
Its a member of UmbracoExamine.SearchCriteria.LuceneSearchExtensions
Regards
Ismail
Thanks a lot!
a last question, where do I input the IbooleanOperation query?
somewhere in here?
Thank for this post... been trying to figure this out!!
where you have SearchTerm.ToLower() just add the MultipleCharacterWildCard() so you have
SearchTerm.ToLower().MultipleCharacterWildCard()
Regards
Ismail
Hi Ismail,
thanks for the reply. The wildcards' working now.
But putting the * before the word doesnt work. So now I can search ' larger* ' and find 'largerword'. But I cannot search ' *word ' and find 'largerword'
Any ideas?
I'm hoping this post will help me as I have the same issue.
To answer your last question Martin, a wild card is not permitted at the start of a search, http://lucene.apache.org/java/2_3_2/queryparsersyntax.html
I learned that already, but thanks anyway.
It's just a weird not really thought out issue with lucene.
although I heard that it is possible to enable it, but hten you have to extend the examine class.
Can somebody tell me what I'm doing wrong?
It won't recognise MultipleCharacterWildcard() as a valid string extension so I cannot compile it.
I have references to Examine & UmbracoExamine and the folowing code:
Thanks, Matt
the MultipleSearchCriteria extension is hidden somewhere deeper within the examine namespace, because otherwise the string extension would pop up everywhere.
I think you only have to add:
Then it will work
Adding that does not work. LuceneSearchExtensions does not exist in that namespace.
Does anyone have an answer to the MultipleCharacterWildCard extension is. I am trying to use it but can't find where it is.
Hmmm this may not help you but I looked back at what I did and ended up using .Fuzzy() instead.
I'm just searching for the first initial of a name so don't really need fuzzy.
But for anyone finding this in the future it seems to be in Examine.LuceneEngine.SearchCriteria.
is working on a reply...