# How to extract the Exact strings or 80% of matched strings from elastic search

**URL:** https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396
**Category:** Elasticsearch
**Created:** [March 17, 2018, 9:31am UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396 "2018-03-17T09:31:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Shaik\_Thowsif](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Shaik\_Thowsif](https://discuss.elastic.co/u/Shaik_Thowsif)
#### Post date: [March 17, 2018, 9:31am UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/1 "2018-03-17T09:31:01Z")

</div>

HI guys,

Actually i want to build an suggestion box, for that i need to suggest the exact String or equivalent to 80% matched strings only.. I have used Auto complete filter, it is providing more irrelevant data to search. So please help me to build an suggestion box.

---

<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: [March 17, 2018, 10:00am UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/2 "2018-03-17T10:00:20Z")

</div>

It's hard to tell what is wrong without seeing what you did so far. Anyway look at [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html)

---

<div class="post-metadata">

### Author: ![Shaik\_Thowsif](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Shaik\_Thowsif](https://discuss.elastic.co/u/Shaik_Thowsif)
#### Post date: [March 17, 2018, 10:31am UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/3 "2018-03-17T10:31:30Z")

</div>

This are the index settings::  
curl -XPUT 'localhost:9200/locations?pretty' -H 'Content-Type: application/json' -d'  
{  
"settings": {  
"number\_of\_shards": 1,  
"analysis": {  
"filter": {  
"autocomplete\_filter": {  
"type": "edge\_ngram",  
"min\_gram": 3,  
"max\_gram": 20  
}  
},  
"analyzer": {  
"autocomplete": {  
"type": "custom",  
"tokenizer": "standard",  
"filter": [  
"lowercase",  
"autocomplete\_filter"  
]  
}  
}  
}  
}  
}  
mappings:::  
curl -XPUT 'localhost:9200/locations/\_mapping/locations?pretty' -H 'Content-Type: application/json' -d'  
{  
"locations": {  
"properties": {  
"country": {  
"type": "text",  
"analyzer": "autocomplete"  
}  
}  
}  
}'

query structure::  
elasticserver.client.search({  
index: locations,  
type: locations,  
body: {  
query: {  
bool: {  
should: [{  
match: {  
country: input  
}  
}]  
}

```
            },
           
            _source: ["country", "country_id", "type"]
        }
    }

```

Actually this giving results by matching input string with words present in sentences..Example:: while i am trying to get "india" related data it is giving indo-tibettan,indonesia etc...  
but i want to get exact matched string data.

---

<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: [March 17, 2018, 10:47am UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/4 "2018-03-17T10:47:35Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

Anyway, add in your mapping a `search_analyzer: simple` for the field you want to search on.

---

<div class="post-metadata">

### Author: ![Shaik\_Thowsif](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Shaik\_Thowsif](https://discuss.elastic.co/u/Shaik_Thowsif)
#### Post date: [March 17, 2018, 12:50pm UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/5 "2018-03-17T12:50:01Z")

</div>

> [@dadoonet](#):
>
> \>

I am getting same set of results after adding "search\_analyzer: simple" in mappings also..  
I have another doubt can we extract exact matched data without applying any analysers?  
Thanks in Advance

---

<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: [March 17, 2018, 1:27pm UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/6 "2018-03-17T13:27:17Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem.

---

<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: [April 14, 2018, 1:27pm UTC](https://discuss.elastic.co/t/how-to-extract-the-exact-strings-or-80-of-matched-strings-from-elastic-search/124396/7 "2018-04-14T13:27:17Z")

</div>

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