# Term proximity based rankings

**URL:** <https://discuss.elastic.co/t/term-proximity-based-rankings/61877>\
**Category:** Elasticsearch\
**Created:** [September 29, 2016, 10:15pm UTC](https://discuss.elastic.co/t/term-proximity-based-rankings/61877 "2016-09-29T22:15:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![calufa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calufa/32/12208_2.png) [@calufa](https://discuss.elastic.co/u/calufa)\
**Post date:** [September 29, 2016, 10:15pm UTC](https://discuss.elastic.co/t/term-proximity-based-rankings/61877/1 "2016-09-29T22:15:09Z")

</div>

Hi there,

I run into a problem and I am hoping you can help me out.

Currently "span\_near" queries return desired results if all the "span\_terms" exists on the results documents. I wonder if its possible to have an "or" inside the clauses, so if one of the terms doesn't exist it still return documents based on term proximity.

Consider these 2 documents:

1. the great fox
2. the black night has come and the great and mighty fox went for dinner

If you query for "the great black fox", ES returns the following:

1. the black night has come and the great and mighty fox went for dinner
2. the great fox

I would like 'the great fox' to be ranked higher even thought is missing 'black'.

Thanks!

---

<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 5, 2017, 10:16pm UTC](https://discuss.elastic.co/t/term-proximity-based-rankings/61877/2 "2017-07-05T22:16:00Z")

</div>


