# Score null when sorting results

**URL:** <https://discuss.elastic.co/t/score-null-when-sorting-results/244647>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [August 12, 2020, 1:00am UTC](https://discuss.elastic.co/t/score-null-when-sorting-results/244647 "2020-08-12T01:00:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpribi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gpribi/32/65066_2.png) [@gpribi](https://discuss.elastic.co/u/gpribi)\
**Post date:** [August 12, 2020, 1:00am UTC](https://discuss.elastic.co/t/score-null-when-sorting-results/244647/1 "2020-08-12T01:00:14Z")

</div>

Hello, when using a sort field, I'm getting every \_meta.score = null value

I'm sorting products by price. When ordering by price asc, I'm getting cheap products that have nothing to do with the query field.

REQUEST

```auto
{
	"query": "zapatillas",
	"page": {
	    "size": 1000,
	    "current": 1
	  },
	"search_fields": {
    		"nombre": { "weight":3 },
    		"descripcion": { "weight":1 },
    		"localnombre": { "weight":1 }
  	},
	"result_fields": {
		"id": { "raw": {} },
	    	"nombre": {"raw": {} },
	    	"idgaleria": {"raw": {} },
	    	"precio": {	"raw": {} },
	    	"foto": {	"raw": {} },
	    	"localdireccion": {	"raw": {} },
	    	"random": {	"raw": {} }
	},
	"sort": {"precio": "asc"}
}

```

RESPONSE

```auto
{
   "meta": {
      "alerts": [],
      "warnings": [],
      "page": {
         "current": 1,
         "total_pages": 1,
         "total_results": 989,
         "size": 1000
      },
      "engine": {
         "name": "productos",
         "type": "default"
      },
      "request_id": "ac65c458-4861-47f8-b84e-657d560d990e"
   },
   "results": [
            {
         "foto": {"raw": "1_thumb.jpg"},
         "precio": {"raw": 63},
         "_meta": {
            "engine": "productos",
            "id": "7118",
            "score": null
         },
         "idgaleria": {"raw": 0},
         "id": {"raw": "7118"},
         "nombre": {"raw": "plantines para zapatilla de dama"},
         "localdireccion": {"raw": "CARACAS 666"},
         "random": {"raw": 7118}
      },
...

```

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [August 13, 2020, 12:58pm UTC](https://discuss.elastic.co/t/score-null-when-sorting-results/244647/2 "2020-08-13T12:58:48Z")

</div>

App Search does some very aggressive matching, which means you'll tend to have very large sets of results, some of which appear are false positives.

If I had to guess, you're most likely getting hits on your description field. Those types of fields tend to have very long text and more possibilities for words to match.

Having large sets of results like this works well as long as relevance is tuned well so that the most relevant results score high.

This can be problematic when you apply a sort, as you've found, as relevance ranking is no longer considered and you now have totally unrelated results appearing first in your result set.

Another option you could explore is instead of applying a sort, you could try boosting results with lower prices via the `search_fields` parameter. [https://www.elastic.co/guide/en/app-search/current/boosts.html](https://www.elastic.co/guide/en/app-search/current/boosts.html)

---

<div class="post-metadata">

**Author:** ![gpribi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gpribi/32/65066_2.png) [@gpribi](https://discuss.elastic.co/u/gpribi)\
**Post date:** [August 23, 2020, 11:43pm UTC](https://discuss.elastic.co/t/score-null-when-sorting-results/244647/3 "2020-08-23T23:43:58Z")

</div>

Thank you @JasonStoltz  
Tried removing the description from the search fields, however I'm still getting many wrong matches just with the title.  
Probably those matches wouldn't appear sorting by score since they match by similarity (for example when searching "parka" I get many matches with "para", a very common spanish preposition)

I'm not sure how to apply the boost, since having a low price isn't always a bad thing. Analyzing just the price, without taking in consideration how similar is the query and the search fields, may produce unexpected results

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [August 24, 2020, 9:53am UTC](https://discuss.elastic.co/t/score-null-when-sorting-results/244647/4 "2020-08-24T09:53:28Z")

</div>

> [@gpribi](#):
>
> when searching "parka" I get many matches with "para", a very common spanish preposition)

See [Options for increasing precision - #5 by Mark\_Harwood](https://discuss.elastic.co/t/options-for-increasing-precision/219920/5)

---

<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:** [September 21, 2020, 9:53am UTC](https://discuss.elastic.co/t/score-null-when-sorting-results/244647/5 "2020-09-21T09:53:35Z")

</div>

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