How to make Lucene search for parts of terms?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make Lucene search for parts of terms?

Artur Tomusiak
Hello,

We are using a MultiFieldQueryParser and we have problems with making
Lucene find parts of words. So that for example searching for "a" will
find all the results that contain "a" in it, not only as a separate
token, but even inside of the tokens (like word "make").

We tried putting wildcards around each search term but then we were
unable to reconstruct the original query because keywords like "AND" or
"OR" are not considered search terms. Also, our analyzer was including
special characters, like '(' as parts of the terms.

Do you know the best way of making this work? We are looking for a way
that would search correctly even more advanced queries, like:

(a OR b) AND c

This should end up finding all results that contain letter 'c' and
either 'a' or 'b' in any of the fields (please remember that we are
using MultiFieldQueryParser).

In the example above, based on our code, wrapping every term in
wildcards ended up with this query:

*(a* *b)* *c*

while we would expect something like this:

(*a* OR *b*) AND *c*

Do you know the best way of accomplishing it?

Thank you,
Artur Tomusiak

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to make Lucene search for parts of terms?

Patrek
Take a look at the ngram classes (probably in contrib, don't remember
for sure right now).

Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]