# What are good combinations of search analyzer, index analyzer and query for implementing an effective autocompleter using ElasticSearch?

**URL:** <https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544>\
**Category:** Elasticsearch\
**Created:** [February 1, 2014, 6:15pm UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544 "2014-02-01T18:15:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [February 1, 2014, 6:15pm UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544/1 "2014-02-01T18:15:38Z")

</div>

Hi,

Elasticsearch is a powerful tool, no doubt but sometimes it can really make  
you cry when you are not able to find out a good combination of index and  
search analyzers along with a good query type for implementing an  
autocompleter. I have read and searched on Internet that this combination  
differs from one use case to another and only way to find out this is to  
try and test it yourself. But can't we generalize this use case to some of  
the extent ?

I'll take a base case where a document contains some title as a string and  
some description as a string. Mostly people implement autocompleter around  
such docs only. And a basic expectation of autocompleter is to find most  
appropriate document corresponding to a user query. A good autocompleter  
gives docs which exactly matches the user query but since user query can  
vary a lot from the actual content, the best autocompleter can do is to  
return docs which contains the maximum user typed terms and that thing is  
accomplished by a good query mechanism. So, can't we generalize a good  
combination for this base case. After that people can just extend that base  
case for other parameters of their docs.

I think people who have spent time with ElasticSearch are aware of pros and  
cons of almost every possible combination of these things. So, it can be a  
good way to start a thread where people can actually share their thoughts,  
experiences and suggestions on different possible combination of analyzers  
and query types so that beginners don't have to struggle a lot initially  
with using ElasticSearch.

I'll start with sharing mine combination (obviously it is not the best one  
but still working on it to improve the effectiveness of my autocompleter):

I have used standard tokenizer along with token filters:  
lowercase,asciifolding,suggestion\_shingle,edgengrams (front). I have used  
same analyzers for both searching and indexing. For the query type, I'm  
using custom score query but somehow the results are not that  
effective/tuned. I expect my autocompleter to give documents which contains  
the maximum matching terms from a user typed query but it's not giving  
results that way.I'm still working on fine tuning it.

I think the above combination solves the problem to a certain extent but  
still there are a hell lot of other ways to go about it which I'm not aware  
of.

I request you people to please give some suggestions, views and share your  
personal experiences of going around this particular problem.

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/81b589c2-b1a1-4f8e-8b3a-8e377e864123%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/81b589c2-b1a1-4f8e-8b3a-8e377e864123%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 1, 2014, 6:33pm UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544/2 "2014-02-01T18:33:09Z")

</div>

There is massive effort to implement autosuggest completion in most  
convenient ways.

Since 0.90.3, there is the Lucene suggester implemented in ES

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)

The Lucene FST is faster and more compact than n-grams and may serve most  
use cases well.

But there is no general solution to autocomplete, like for search in  
general. It depends on the words in the index and how to search them. E.g.  
for german language, you probably need extra analysis for normalization  
forms, like decompounding and baseform reduction, to better support what  
the user wants.

If you look at (older) solutions that do not use Lucene FST, you can use  
edgeNgram, a linguistic method that takes considerably more space. A demo  
is here

[http://jprante.github.io/applications/2012/08/17/Autocompletion-with-jQuery-JAX-RS-and-Elasticsearch.htm](http://jprante.github.io/applications/2012/08/17/Autocompletion-with-jQuery-JAX-RS-and-Elasticsearch.htm)

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEQve7qhKOLL4gFzZnt4zcoNcFUYYwSiKOPO1pE\_rtRCA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEQve7qhKOLL4gFzZnt4zcoNcFUYYwSiKOPO1pE_rtRCA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [February 1, 2014, 6:40pm UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544/3 "2014-02-01T18:40:23Z")

</div>

Jorg

The second link is not working. Completion suggester is a good thing but it  
is restricted to prefix queries only I guess. You will have to give every  
possible combination of a user typed query for a document to be matched.  
Please correct me if I;m wrong

Thanks

On Sunday, 2 February 2014 00:03:09 UTC+5:30, Jörg Prante wrote:

> There is massive effort to implement autosuggest completion in most  
> convenient ways.
> 
> Since 0.90.3, there is the Lucene suggester implemented in ES
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)
> 
> The Lucene FST is faster and more compact than n-grams and may serve most  
> use cases well.
> 
> But there is no general solution to autocomplete, like for search in  
> general. It depends on the words in the index and how to search them. E.g.  
> for german language, you probably need extra analysis for normalization  
> forms, like decompounding and baseform reduction, to better support what  
> the user wants.
> 
> If you look at (older) solutions that do not use Lucene FST, you can use  
> edgeNgram, a linguistic method that takes considerably more space. A demo  
> is here
> 
> [http://jprante.github.io/applications/2012/08/17/Autocompletion-with-jQuery-JAX-RS-and-Elasticsearch.htm](http://jprante.github.io/applications/2012/08/17/Autocompletion-with-jQuery-JAX-RS-and-Elasticsearch.htm)
> 
> Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/720c3be5-f5cf-4385-a6ba-da1263442290%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/720c3be5-f5cf-4385-a6ba-da1263442290%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 1, 2014, 7:19pm UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544/4 "2014-02-01T19:19:04Z")

</div>

No, suggester is not restricted to prefix, in 0.90.4 fuzziness was added,  
as documented. Fuzzy suggest completion means your query may contain errors  
within an edit distance.

Fixed link (the final 'l' was truncated)

[http://jprante.github.io/applications/2012/08/17/Autocompletion-with-jQuery-JAX-RS-and-Elasticsearch.html](http://jprante.github.io/applications/2012/08/17/Autocompletion-with-jQuery-JAX-RS-and-Elasticsearch.html)

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHx0bN2uOvEtJJuKxbCAyL%2BeK2dWWF%3Dx0R-JS-QnXkvHw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHx0bN2uOvEtJJuKxbCAyL%2BeK2dWWF%3Dx0R-JS-QnXkvHw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 3, 2014, 10:17am UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544/5 "2014-02-03T10:17:39Z")

</div>

On 1 February 2014 20:19, [joergprante@gmail.com](mailto:joergprante@gmail.com) [joergprante@gmail.com](mailto:joergprante@gmail.com)wrote:

> No, suggester is not restricted to prefix, in 0.90.4 fuzziness was added,  
> as documented. Fuzzy suggest completion means your query may contain errors  
> within an edit distance.

But, it is still a prefix suggester... You can't mix up the order of  
words. This works really well for well formulated names eg song titles.  
But for general search it can fail to match.

it's worth using the completion suggester as the first-line search and  
falling back to edge ngrams if there are no matches.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT5kfXoen%3DO2a%3D0yP9SuGjyvEh9E21ZLDc%2BZ\_KMdyHuQA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT5kfXoen%3DO2a%3D0yP9SuGjyvEh9E21ZLDc%2BZ_KMdyHuQA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:53am UTC](https://discuss.elastic.co/t/what-are-good-combinations-of-search-analyzer-index-analyzer-and-query-for-implementing-an-effective-autocompleter-using-elasticsearch/15544/6 "2017-07-06T01:53:13Z")

</div>


