In Solr (3.3), is it possible to make a field letter-by-letter searchable through a EdgeNGramFilterFactory
and also sensitive to phrase queries?
By example,
As alas I could not manage to use a PositionFilter
right like Jayendra Patil suggested (PositionFilter makes any query a OR boolean query), I used a different approach.
Still with the EdgeNGramFilter
, I added the fact that each keyword the user typed in is mandatory, and disabled all phrases.
So if the user ask for "cont info"
, it transforms to +cont +info
. It's a bit more permissive that a true phrase would be, but it managed to do what I want (and doesn't return results with only one term from the two).
The only con against this workaround is that terms can be permutated in the results (so a document with "informatique contrat" will also be found), but it's not that a big deal.