# Sort by term position, ignoring term freqs

**URL:** <https://discuss.elastic.co/t/sort-by-term-position-ignoring-term-freqs/285611>\
**Category:** Elasticsearch\
**Created:** [September 30, 2021, 3:36pm UTC](https://discuss.elastic.co/t/sort-by-term-position-ignoring-term-freqs/285611 "2021-09-30T15:36:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maurienvy](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@maurienvy](https://discuss.elastic.co/u/maurienvy)\
**Post date:** [September 30, 2021, 3:36pm UTC](https://discuss.elastic.co/t/sort-by-term-position-ignoring-term-freqs/285611/1 "2021-09-30T15:36:16Z")

</div>

Hello everyone! I want to do a search that allows me to sort the results depending on wether the terms that I am looking for are closer to the beggining of the text field, and ignore term frequency altogether.

So for example, if I have three documents:

```auto
GET /products/doc/1
{ 
"title" : "Laptop Lenovo" 
}

GET /products/doc/2
{ 
"title" : "HP Laptop" 
}

GET /products/doc/3
{ 
"title" : "Desk Stand Laptop"
 }

```

And I search "laptop", I want the order of the results to be: 1 , 2 , 3 , and this is ordered depending on the "position" of the word "laptop".

Now, reading the index\_options documentations, it seems like I cannot ignore term\_freqs without disabling term\_position too, so what I tried to do is , I set up a "unique" filter on the "title" text field, so that when indexing, it doesnt matter how many times any word is, but this is still not giving me correct results.

How do I accomplish this?

---

<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:** [October 28, 2021, 3:37pm UTC](https://discuss.elastic.co/t/sort-by-term-position-ignoring-term-freqs/285611/2 "2021-10-28T15:37:07Z")

</div>

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