lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Corbin, J.D." <>
Subject SynonymGraphFilter Usage
Date Thu, 09 Feb 2017 21:31:39 GMT
I am using the SynonymGraphFilter(SGF) in a custom analyzer (query side
only) and when I print out the query generated from the QueryParser, it
displays some clauses that I would like to understand.  I am not sure I'm
using the SGF  properly.

Example Query output:(using Lucene 6.4.1)

..., (Synonym(title:cardiogram title:ecg title:ekg title:electrocardiogram)
... Graph(title:adobe title:brick, title:adobe, hasBoolean=true,

I'm curious if this is expected form when printing a query that uses the
SynonymGraphFilter and what is the difference between the 'Synonym' and
'Graph' output when printing the query.

The documentation on the filter suggest using
TokenStreamToTermAutomatonQuery, but not sure in what context I should use
it and how.

My final query is built by using the BooleanQuery.Builder class which
combines sub queries built using QueryParser.

Here is how I am currently specifying the filter in my custom analyzer:

TokenStreamComponents createComponents(String fieldName) {
      ... tokenizer, other filters, etc...
      SynonymMap synonyms = getSynonyms();
      if (synonyms != null) {
         result = new SynonymGraphFilter(result, synonyms, true);
      result = new StopFilter(result, stopwords);
      ...more filters
     return TokenStreamComponents(source, result);


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message