This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello-
I am implementing the Lucene searching for the first time and am having troubles getting expected results back.
I am using Mindscape 2.2 with a SQLite3 database (the same results happen with MySQL, if that matters) with Visual Studio 2008.
The search configuration is set up according to the 'Configuration' section of the Reference Guide, specifically:
searchEngineClass="Mindscape.LightSpeed.Search.LuceneSearchEngine"
and an appropriate searchEngineFileLocation Because I am dropping this into an existing database, I run the rebuild:
SearchEngine.Rebuild(IsolationLevel.Serializable, typeof(Person));
The directory is there and the search index files are updated underneath it.
Person contains a column FullName which is, cleverly enough, a person's name. The data in this table, for example, is
Id=1 FullName=Peter Remillard Id=2 FullName=Milla Jackson Note that both names contain 'milla',
Now, to search, I execute this:
QueryExpression exp = Entity.Attribute(Person.FullNameField).Like("Milla"); IList<SearchResult> results = work.Search(exp.ToString(), typeof(Person)); which returns one result, Id=2 Milla Jackson. I was expecting both results.
Changing the query to lowercase ...Like("milla") returns Id=2 again. For grins I tried ...Like("%milla%") and still only Entity Id=2 was returned.
Running a similary constructed query directly against the SQLite (and MySQL) table, for example,
select * from person where fullname like '%milla%'
returns both Id=1 and Id=2. I realize this isn't really what Lucene is up to but at least it indicates my data is there.
I figure I'm doing something wrong here but am unable to find any documentation to help me out. Is it a SQLite3 thing or a configuration problem? Perhaps I am misreading the Reference somewhere?
Any suggestions or recommendations most welcome.
Best regards,
Lionel |
|
|
Hello- For anyone following this post, first I apologize for the format of the original - if anyone knows how to edit it so it's more readable, I'd be happy to do so. Just for posterity in the event anyone else searches on this topic... I looked into this a bit more and think the problem is that 'Like' seems to operate only on WORDS as opposed to BITS of words. So a search for 'milla' will only find Id=2 while a search for 'mill' will find no results. Likewise, a search for 'remillard' will find Id=1 and 'Jackson' will find Id=2. That seems a bit weird to me but again, I am rather new to Lucene and so perhaps am overlooking something obvious or have incorrect expectations. I was hoping there would be a way to simulate a "select * from Person where name like '%milla%'". Any suggestions or clarifications would be most welcome. Have a great day! Regards, |
|
|
Hi Lionel, Thank you for your feedback. It sounds like you're on the right track however to add some suggestions:
See if that works for you and, if not, let me know. It may be a case where tweaking the SearchEngine implementation is needed. I hope that helps, John-Daniel Trask P.S. You mention that you're new to Lucene. If you haven't used it, Luke ( http://www.getopt.org/luke/ ) is a great tool for helping debug and test against your Lucene index that gets generated. The one generated by LightSpeed is a standard Lucene index so you can use Luke with it. |
|
|
Mr. Trask- Thank you for the links; they both helped me tremendously. I appreciate your time very much and I was able to craft a satisfactory search. I'll work on the remaining ingredients another time. Those being ideally: IList<SearchResult> results = work.Search("FullName like *milla*", typeof(Person)); but Lucene doesn't support beginning wildcards. I have enough for now to proceed with the project and can deal with that later. For posterity, I'll just add these bits of information for anyone who might follow with similar questions or problems and search the forums for the terms I did. [ Irony is fun ] Leading wildcards aren't supported in Lucene and attempting to do so throws an exception: Message "Lexical error at line 1, column 11. Encountered: \"*\" (42), after : \"\"" string Just in case anyone searches for this sort of thing in the future. Thank you again for your time. Best regards, |
|