# Rank Feature vs. Decay

**URL:** <https://discuss.elastic.co/t/rank-feature-vs-decay/261403>\
**Category:** Elasticsearch\
**Created:** [January 18, 2021, 10:10am UTC](https://discuss.elastic.co/t/rank-feature-vs-decay/261403 "2021-01-18T10:10:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaigbdb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaigbdb/32/74219_2.png) [@shaigbdb](https://discuss.elastic.co/u/shaigbdb)\
**Post date:** [January 18, 2021, 10:10am UTC](https://discuss.elastic.co/t/rank-feature-vs-decay/261403/1 "2021-01-18T10:10:05Z")

</div>

Hi,  
I'm trying rank feature for a rank field, and comparing the results to a function score using a gauss decay function on a similarly-valued float field. The results are pre-filtered with a geo\_distance query in both cases.  
I've tried changing parameters for both the query and the function, but no matter what I do, I get the following:  
The 9th and 10th result for rank\_feature are switched in the order of rank, as opposed to function score which gets them "right".  
What am I missing?

function score query:

```auto
{
  "query": {
    "function_score": {
      "functions": [

        {
          "gauss": {
            "rank": {
              "origin": "1.176285743713379",
              "scale": "0.52"
            }
          }
        }
      ],
      "boost_mode": "replace", 
      "query": {
            "bool": {
      "filter": {
        "geo_distance": {
          "distance": "1km",
          "startPoint": {
            "lat": 32.0691,
            "lon": 34.818733
          }
        }
      }
            }
        
      }
    }
  },
    "_source": [
      "rank"
    ]
}

```

rank\_feature query:

```auto
{
  "track_total_hits": false,
      "query": {
        "bool": {
          "filter": {
            "geo_distance": {
              "distance": "1000m",
              "startPoint": {
                "lat": 32.0691,
                "lon": 34.818733
              }
            }
          },
          "should": [
            
            {
        "rank_feature": {
          "field": "rank_feature"
        }
            }
          ]
        }
      },
    "_source": [
      "rank"
    ]
}

```

rank\_feature results (notice the last two at the bottom when scrolling down):

```auto
  {
    "_source" : {
      "rank" : 0.5111902543796677
    }
  },
  {
    "_source" : {
      "rank" : 0.5
    }
  },
  {
    "_source" : {
      "rank" : 0.46628138522373463
    }
  },
  {
    "_source" : {
      "rank" : 0.4417490478510222
    }
  },
  {
    "_source" : {
      "rank" : 0.4376207403170089
    }
  },
  {
    "_source" : {
      "rank" : 0.4357255666844616
    }
  },
  {
    "_source" : {
      "rank" : 0.43511569723807253
    }
  },
  {
    "_source" : {
      "rank" : 0.4336625204125677
    }
  },
  {
    "_source" : {
      "rank" : 0.43122650407429886
    }
  },
  {
    "_source" : {
      "rank" : 0.43133425965676375
    }
  }

```

Thanks,  
Shai

---

<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:** [February 15, 2021, 10:10am UTC](https://discuss.elastic.co/t/rank-feature-vs-decay/261403/2 "2021-02-15T10:10:10Z")

</div>

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