# When sorting by distance truncating the distance sort value for fallback sort criteria

**URL:** <https://discuss.elastic.co/t/when-sorting-by-distance-truncating-the-distance-sort-value-for-fallback-sort-criteria/312055>\
**Category:** Elasticsearch\
**Created:** [August 13, 2022, 2:50pm UTC](https://discuss.elastic.co/t/when-sorting-by-distance-truncating-the-distance-sort-value-for-fallback-sort-criteria/312055 "2022-08-13T14:50:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quesurifn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quesurifn/32/109608_2.png) [@quesurifn](https://discuss.elastic.co/u/quesurifn)\
**Post date:** [August 13, 2022, 2:50pm UTC](https://discuss.elastic.co/t/when-sorting-by-distance-truncating-the-distance-sort-value-for-fallback-sort-criteria/312055/1 "2022-08-13T14:50:21Z")

</div>

Hello all,

We're sorting with elasticsearch like so:

```auto
  {
      "size": 300,
      "from": 0,
      "sort": [
        {
          "_geo_distance": {
            "geoLocation": {
              "lat": 29.7407,
              "lon": -95.4636
            },
            "distance_type": "arc",
            "unit": "mi",
            "order": "asc"
          }
        },
        {
          "profileCompletenessPercentage": "desc"
        },
        {
          "galleryPhotoCount": "desc"
        }
      ],
      "query": {
        "bool": {
          "filter": {
            "geo_distance": {
              "geoLocation": {
                "lat": 29.7407,
                "lon": -95.4636
              },
              "distance_type": "arc",
              "distance": "10mi"
            }
          }
        }
      },
      "aggs": {
        "totals": {
          "global": {
            
          }
        }
      }
    }

```

The distance values are 17 decimal places `"sort":[4.230084424066245,50,0]` so our secondary sort criteria is never hit because we want a precision of one decimal place.

How can we accomplish our goal of multi-sort with Elasticsearch where the precision for geolocation is 4.2 not 4.230084424066245?

---

<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 10, 2022, 2:50pm UTC](https://discuss.elastic.co/t/when-sorting-by-distance-truncating-the-distance-sort-value-for-fallback-sort-criteria/312055/2 "2022-09-10T14:50:36Z")

</div>

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