# Elasticsearch - How to list exact match at the top

**URL:** <https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251>\
**Category:** Elasticsearch\
**Created:** [October 5, 2018, 5:01pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251 "2018-10-05T17:01:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![somethingyouwant](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somethingyouwant](https://discuss.elastic.co/u/somethingyouwant)\
**Post date:** [October 5, 2018, 5:01pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251/1 "2018-10-05T17:01:25Z")

</div>

I am searching the word "Adana" in Elasticsearch and want it to come at top because it is the exact word, but it doesn't.

Instead "Bilmemne Adana Otel" comes at top.

Normal query doesn't do any good so I tried the boolean query with "must" and "should". But it doesn't change anything too.

In addition to that, if i write "Ada" the "Adana" should come first too.

How can we make it work right?

Query:

```auto
curl -X GET "localhost:9200/destinations/_search" -H 'Content-Type: 
application/json' -d'
{
 "query": {
   "match": {
     “Name”: {
       "query": “Adana”
      }
    }
  }
}
'

```

Result:

```auto
{
"took" : 16,
"timed_out" : false,
"_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
},
"hits" : {
    "total" : 3,
    "max_score" : 3.255435,
    "hits" : [
    {
        "_index" : "destinations",
        "_type" : "_doc",
        "_id" : "10",
        "_score" : 3.255435,
        "_source" : {
        "name" : "Bilmemne Adana Otel"
        }
    },
    {
        "_index" : "destinations",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : 2.8624198,
        "_source" : {
        "name" : "Adana"
        }
    },
    {
        "_index" : "destinations",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 2.3216834,
        "_source" : {
        "name" : "Adana Airport Otel - Adana"
        }
    }
    ]
}
}

```

Index:

```auto
{
"settings": {
    "analysis": {
    "filter": {
        "autocomplete_filter": {
        "type": "edge_ngram",
        "min_gram": 2,
        "max_gram": 15
        }
    },
    "analyzer": {
        "autocomplete": { 
        "type": "custom",
        "tokenizer": "standard",
        "filter": [
            "lowercase",
            "autocomplete_filter"
        ]
        }
    }
    }
},
"mappings": {
    "_doc": {
    "properties": {
        "name": {
        "type": "text",
        "analyzer": "autocomplete", 
        "search_analyzer": "standard" 
        }
    }
    }
}
}

```

---

<div class="post-metadata">

**Author:** ![somethingyouwant](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somethingyouwant](https://discuss.elastic.co/u/somethingyouwant)\
**Post date:** [October 8, 2018, 2:16pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251/2 "2018-10-08T14:16:38Z")

</div>

Can i bump this? It is a very important question for me. Isn't there no one that can answer it?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 9, 2018, 12:55pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251/3 "2018-10-09T12:55:39Z")

</div>

You can combine multiple queries.

Like in this example:

> <https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab>

---

<div class="post-metadata">

**Author:** ![somethingyouwant](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somethingyouwant](https://discuss.elastic.co/u/somethingyouwant)\
**Post date:** [October 10, 2018, 8:07am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251/4 "2018-10-10T08:07:58Z")

</div>

How can combining multiple queries will help? It that example you give you boost different queries but they are just different like "fuzzy search, at least one term, two terms at the same time etc..."

How can i say "complete to the closest word: Like if you write "Lon" it will get you "London" first. And "Londonwit" or "Londowit" second etc...

---

<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:** [November 7, 2018, 8:17am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-list-exact-match-at-the-top/151251/5 "2018-11-07T08:17:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
