On Mon, 2011-12-19 at 01:22 -0800, George Sakkis wrote:
Unfortunately this doesn't seem to be enough, at least for broad
prefix queries there is a two orders of magnitude difference in my
index. Here's my original query, it takes ~650ms for 25 hits:
The problem with your query is not filter vs query, it is the use of the
prefix query (or filter for that matter).
It is not an efficient search. It has to:
- load all terms
- find all terms beginning with 'm'
- limit those to the 1024 most relevant 'm' terms
- do 1024 searches
prefix clauses are ok when you have few terms, but not for general use.
What you want to do is to prepare your data properly, ie index
appropriate fields with the 'edgeNGram' token filter, which will produce
Then a search for eg 'ma' will be quick.
Note: your search_analayzer should NOT include the edgeNGram filter,
otherwise it'll search for 'm','ma' etc
have a look at this previous reply for more detail: