# Sorting by number of matched terms with simple\_query\_string

**URL:** https://discuss.elastic.co/t/sorting-by-number-of-matched-terms-with-simple-query-string/25159
**Category:** Elasticsearch
**Created:** [July 8, 2015, 2:58pm UTC](https://discuss.elastic.co/t/sorting-by-number-of-matched-terms-with-simple-query-string/25159 "2015-07-08T14:58:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Emily\_Craps](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@Emily\_Craps](https://discuss.elastic.co/u/Emily_Craps)
#### Post date: [July 8, 2015, 2:58pm UTC](https://discuss.elastic.co/t/sorting-by-number-of-matched-terms-with-simple-query-string/25159/1 "2015-07-08T14:58:58Z")

</div>

Hi,

I'm implementing free text search in a web application. The user is able to search like with google, he can use the + and - signs etc. It is easy to implement with the simple\_search\_query and works perfectly. I am currently sorting by the relevance score provided by elasticsearch, but I want to sort on the number of matched search terms, it doesn't matter how many times a term is present in a document. It could be done like this [constant score query](https://www.elastic.co/guide/en/elasticsearch/guide/current/ignoring-tfidf.html#ignoring-tfidf) example, but then I'll have to parse the query string in the application and split it in terms.

Is there a way to have both done by elasticsearch?

---

<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, 12:02am UTC](https://discuss.elastic.co/t/sorting-by-number-of-matched-terms-with-simple-query-string/25159/2 "2017-07-06T00:02:52Z")

</div>


