# Results ranking on empty query ""

**URL:** <https://discuss.elastic.co/t/results-ranking-on-empty-query/325225>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [February 10, 2023, 8:50am UTC](https://discuss.elastic.co/t/results-ranking-on-empty-query/325225 "2023-02-10T08:50:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerardo\_Zenobi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gerardo_zenobi/32/106790_2.png) [@Gerardo\_Zenobi](https://discuss.elastic.co/u/Gerardo_Zenobi)\
**Post date:** [February 10, 2023, 8:50am UTC](https://discuss.elastic.co/t/results-ranking-on-empty-query/325225/1 "2023-02-10T08:50:10Z")

</div>

Hi there 👋

I wanted to know how EAP ranks / orders results when we perform a search with an empty query, for example, like so:

```auto
POST /api/as/v1/engines/my-engine/search.json

{"query":"", "page":{"size":50}}

```

From the [documentation](https://www.elastic.co/guide/en/app-search/current/search.html#search-api-request-body) it is clear that it matches all documents but would like to understand the order in which they are returned.

Furthermore, would boosting rules that are configured in the engine continue to be respected in such scenario ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![demjened](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/demjened/32/109159_2.png) [@demjened](https://discuss.elastic.co/u/demjened)\
**Post date:** [February 10, 2023, 11:17pm UTC](https://discuss.elastic.co/t/results-ranking-on-empty-query/325225/2 "2023-02-10T23:17:05Z")

</div>

Hi @Gerardo_Zenobi, since the empty query string equally matches all documents, the assigned score is 1.0 for each document (you can check this under the `_meta.score` property of the resulting hits). Therefore the sorting is not deterministic.

If you want to sort the results in this scenario, check out the [sorting controls documentation](https://www.elastic.co/guide/en/app-search/current/sort.html).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Gerardo\_Zenobi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gerardo_zenobi/32/106790_2.png) [@Gerardo\_Zenobi](https://discuss.elastic.co/u/Gerardo_Zenobi)\
**Post date:** [February 13, 2023, 9:50am UTC](https://discuss.elastic.co/t/results-ranking-on-empty-query/325225/3 "2023-02-13T09:50:57Z")

</div>

Thanks for the answer @demjened.

I did notice the scores on my empty query results were all the same.

In my case, the value is `21`. I believe that it is because I have 2 value boosts on two different fields set to `10` which would explain the 20 points. And would confirm boosts take place in empty query searches.

However, I have multiple searchable fields in my engine schema, does the document only get's a `1` on empty queries even though we might have multiple fields to search in ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![demjened](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/demjened/32/109159_2.png) [@demjened](https://discuss.elastic.co/u/demjened)\
**Post date:** [February 13, 2023, 9:52pm UTC](https://discuss.elastic.co/t/results-ranking-on-empty-query/325225/4 "2023-02-13T21:52:09Z")

</div>

Hmm, interesting. I replicated your setup on Elastic Cloud version 8.7:

- Created a search engine with an underlying index
- Set the weight of two fields to 10, left the others at the default 1
- Ran this query:

```auto
{"query":"", "page":{"size":50}}

```

I checked the native Elasticsearch query that was generated and executed by the engine, and found no trace of the configured weights (boosts):

```auto
{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      }
    }
  },
  "sort": [
    {
      "_score": "desc"
    },
    {
      "_doc": "desc"
    }
  ],
  "size": 50,
  "from": 0
  // Other controls such as _source, highlight...
}

```

All hits in the resultset have a constant score of 1.0.

It is only when I pass an actual value in `query` that the generated query includes various boosts on the weighted fields and subfields, and the hits' scores differ.

Is your experience different from this? If so, let me know what version you are on.

---

<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:** [March 13, 2023, 9:52pm UTC](https://discuss.elastic.co/t/results-ranking-on-empty-query/325225/5 "2023-03-13T21:52:18Z")

</div>

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