Details

Description

I apologize for bringing the multi-token synonym expansion up again. There is an old, unresolved issue at LUCENE-1622[1]

While solving the problem for our needs [2], I discovered that the current SolrSynonym parser (and the wonderful FTS) have almost everything to satisfactorily handle both the query and index time synonym expansion. It seems that people often need to use the synonym filter slightly differently at indexing and query time.

In our case, we must do different things during indexing and querying.

We need the original tokens for the proximity queries, if we indexed 'hubble space telescope'
as one token, we cannot search for 'hubble NEAR telescope'

You may (not) be surprised, but Lucene already supports ALL of these requirements. The patch is an attempt to state the problem differently. I am not sure if it is the best option, however it works perfectly for our needs and it seems it could work for general public too. Especially if the SynonymFilterFactory had a preconfigured sets of SynonymMapBuilders - and people would just choose what situation they use. Please look at the unittest.