# Elastic Search - Search Query More weightage to exact matches

**URL:** https://discuss.elastic.co/t/elastic-search-search-query-more-weightage-to-exact-matches/16831
**Category:** Elasticsearch
**Created:** [April 5, 2014, 8:29pm UTC](https://discuss.elastic.co/t/elastic-search-search-query-more-weightage-to-exact-matches/16831 "2014-04-05T20:29:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Pratik\_Poddar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pratik_poddar/32/1529_2.png) [@Pratik\_Poddar](https://discuss.elastic.co/u/Pratik_Poddar)
#### Post date: [April 5, 2014, 8:29pm UTC](https://discuss.elastic.co/t/elastic-search-search-query-more-weightage-to-exact-matches/16831/1 "2014-04-05T20:29:13Z")

</div>

I have implemented a news search engine on elastic search. I have indexed  
the articles and run the search query as following. When I search for "A B  
C", I want the search engine to give more weightage to exact matches of "A  
B C" \> "A B" / "B C" \> "A" / "B" / "C". Its not happening. How can I change  
the search query to reflect this?

```
es.indices.create(
        index="article-index",
        body={
                'settings': {
                        'analysis': {
                                'analyzer': {
                                        'my_ngram_analyzer' : {
                                                'tokenizer' : 'my_ngram_tokenizer'
                                        }
                                },
                                'tokenizer' : {
                                        'my_ngram_tokenizer' : {
                                                'type' : 'nGram',
                                                'min_gram' : '1',
                                                'max_gram' : '50'
                                        }
                                }
                        }
                }
        },
        # ignore already existing index
        ignore=400
)

```

res = es.search(index="article-index", fields="url", body={"query": {"query\_string": {"query": keywordstr}})

--  
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/8fc93f16-b207-4fa5-ba17-644e7ad12c9c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fc93f16-b207-4fa5-ba17-644e7ad12c9c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:37am UTC](https://discuss.elastic.co/t/elastic-search-search-query-more-weightage-to-exact-matches/16831/2 "2017-07-06T01:37:57Z")

</div>


