Lucene synonym for multi-words and query parsers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Lucene synonym for multi-words and query parsers

Nicolás Lichtmaier

As far as I can see Lucene new support for multi word synonyms doesn't work with non-phrase inputs. The analyzer can correctly create the graph, but it doesn't have the chance because query parsers process word by word.

Am I missing something?

Here are some tests I've done... (synonyms are just "go to => open").


Thanks!

Nicolás.-


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lucene synonym for multi-words and query parsers

sarowe
Hi Nicolas,

Classic QueryParser and SimpleQueryParser should work for you (see below).  Some work has been done on StandardQueryParser (see <https://issues.apache.org/jira/browse/LUCENE-7315>), but that work is not ready yet.  AFAIK nobody has worked on enabling multi-term analysis in ComplexPhraseQueryParser’s.

For Classic QueryParser, use setSplitOnWhitespace(false).  See <http://lucene.apache.org/core/6_5_0/queryparser/org/apache/lucene/queryparser/classic/QueryParser.html#setSplitOnWhitespace-boolean->.

For SimpleQueryParser, you can enable multi-term analysis by disabling only the whitespace “operator” via the constructor taking the flags option <http://lucene.apache.org/core/6_5_0/queryparser/org/apache/lucene/queryparser/simple/SimpleQueryParser.html#SimpleQueryParser-org.apache.lucene.analysis.Analyzer-java.util.Map-int->, e.g.

new SimpleQueryParser(analyzer, Collections.singletonMap("field", 1f), ~SimpleQueryParser.WHITESPACE_OPERATOR);

--
Steve
www.lucidworks.com

> On Apr 12, 2017, at 11:49 AM, Nicolás Lichtmaier <[hidden email]> wrote:
>
> As far as I can see Lucene new support for multi word synonyms doesn't work with non-phrase inputs. The analyzer can correctly create the graph, but it doesn't have the chance because query parsers process word by word.
>
> Am I missing something?
> Here are some tests I've done... (synonyms are just "go to => open").<Captura de pantalla de 2017-04-12 12-41-09.png>
>
>
> Thanks!
>
> Nicolás.-
>
>


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

Loading...