Hi,

I think your issue is that you are also applying the edge n-gram filter at
search time. So "happy" is translated to ("ha" OR "hap" OR "happ" OR
"happy"). You need to configure your mappings with a search analyzer[1]
which is the same analyzer but without the edge-ngram filter (so just
keyword and lowercase).

On a side note, you would benefit from putting the lowercase filter in
front of your n-gram filter. This way, the lowercasing would be done only
once.

[1]
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#string


On Mon, Apr 28, 2014 at 10:50 AM, cyrilforce <[email protected]> wrote:

> Hi All,
>
> I am trying to use *edge-ngram filter *to achieve auto-completion
> behaviour. However when i run the following query :
>
> {
>     "from" : "0",
>     "size" : "20",
>     "explain" : true,
>
>     "query" : {
>     *"multi_match": {*
> *      "query": "happy",*
> *      "fields": [ "DISPLAY_NAME.NAME <http://DISPLAY_NAME.NAME>"]*
> *     }*
>     },
>     "sort" : [{
>       "_score" : { "order" : "desc"}}]
> }
>
> It returns me documents  :
>
> https://gist.github.com/cheehoo/11365794
>
>
> May i know how can i achieve the behaviour when i search "*happy*" then
> is should return me following result instead :
>
> *1)Happy*
> *2)Happy birthday*
> *3)Happy valentine*
>
>
> The analzyer configure :
>
> "analysis" : {
> "analyzer" : {
> "edge_ngram_keyword_lowercase_analyzer" : {
> "tokenizer" : "keyword",
> "filter" : ["my_edge_ngram_filter","lowercase"]
> }
> },
>  "filter" : {
>                     "my_edge_ngram_filter" : {
>                         "type" : "edgeNGram",
>                         "min_gram" : "2",
>                         "max_gram" : "30"
>
>                     }
>                 }
>  }
>
>
> The mapping :
> https://gist.github.com/cheehoo/11365917
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/e8a4446c-38c9-4c6b-8d2a-15374ef041a9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adrien Grand

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5iMm-e%3Dk-vf6_Hw%3D7EDgNzoG%2BrQLfAW6-pJdw1JbJYYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to