Hi dan

I tried this before however it returns me some irrelevant result as well :
https://gist.github.com/cheehoo/11365794

How I could get only the relevant result with the sorting via edge ngram ?
Thanks
On Apr 28, 2014 7:36 PM, "Dan Tuffery" <[email protected]> wrote:

> To return the query results in the order you want, execute the sort on a
> not_analyzed version of the term, i.e
>
> "DISPLAY_NAME": {
>     "type": "string",
>     "fields": {
>          "NAME": {
>               "type": "string",
>              "analyzer": "edge_ngram_keyword_lowercase_analyzer"
>         },
>         "untouched":{
>              "type": "string",
>                   "analyzer":"not_analyzed"
>               }
>         }
> }
>
> Reindex the data. Now in your query you can sort on the 'untouched' field:
>
> {
>     "from" : "0",
>     "size" : "20",
>     "explain" : true,
>
>     "query" : {
>     "multi_match": {
>          "query": "happy",
>           "fields": [ "DISPLAY_NAME.name"]
>      }
>     },
>     "sort" : [{
>       "DISPLAY_NAME.untouched" : { "order" : "desc"}}]
> }
>
> which will return
>
> *1)Happy*
> *2)Happy birthday*
> *3)Happy valentine*
>
> Dan
>
>
> On Monday, April 28, 2014 9:50:44 AM UTC+1, cyrilforce 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 a topic in the
> Google Groups "elasticsearch" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elasticsearch/fhsCgFBF76E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/7ad16d4e-aed3-474e-893d-92cc788003b0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGS0%2Bg-yN%3DBa5%2BUgCcSwz4hVeAbo8O0c2BV1Wod1zvsKb_QzKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to