ElasticSearch Facets术语查询浮点精度

时间:2017-01-18 09:03:18

标签: elasticsearch facet

我对facet术语查询有一些问题(使用ElasticSearch 1.7.0),所有浮点值都存储在数据库和elasticsearch体积中,但是当我请求数据时,我得到的值就像那样&# 34; 2.99000000954"

奇怪的是,当我向" 2.99000000954"提出请求时,引擎找到了与此数据相关的好文章,该文章带有" 2.99"值。

请查看以下代码文件和卷曲呼叫请求:

映射(来自_plugin / head)

"pvi": {
    "include_in_all": false,
    "type": "float",
    "fields": {
        "raw": {
            "type": "float"
        },
        "sort": {
            "type": "float"
        }
    }
}

elastic_bulk_Article_en_XXX.json0

{
  "pvi": [
    "2.99"
  ],
}

卷曲调用

curl -XGET 'http://elasticsearch:9200/entrepriseName_search_index_fr_fr/Article/_search' -d '{"query":{"filtered":{"query":{"match_all":{}},"filter":[]}},"aggs":{"pvi":{"filter":{"query":{"query_string":{"query":"*","fuzzy_prefix_length":1,"fields":["pvi"]}}},"aggs":{"pvi":{"terms":{"field":"pvi","size":25,"order":{"_term":"asc"}}}}}},"size":0}'

卷曲调用结果

{
  "aggregations": {
    "pvi": {
      "doc_count": 1007,
      "pvi": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 0,
        "buckets": [
          {
            "key": 1,
            "doc_count": 1
          },
          {
            "key": 2.99000000954,
            "doc_count": 1
          },
          {
            "key": 3.99000000954,
            "doc_count": 6
          },
          {
            "key": 4.98999977112,
            "doc_count": 33
          },
          {
            "key": 5.98999977112,
            "doc_count": 46
          },
          {
            "key": 6.98999977112,
            "doc_count": 11
          },
          {
            "key": 7.98999977112,
            "doc_count": 69
          },
          {
            "key": 9.98999977112,
            "doc_count": 78
          },
          {
            "key": 12.9899997711,
            "doc_count": 107
          },
          {
            "key": 15.9899997711,
            "doc_count": 135
          },
          {
            "key": 17.9899997711,
            "doc_count": 60
          },
          {
            "key": 19.9899997711,
            "doc_count": 158
          },
          {
            "key": 22.9899997711,
            "doc_count": 17
          },
          {
            "key": 25.9899997711,
            "doc_count": 143
          },
          {
            "key": 27.9899997711,
            "doc_count": 2
          },
          {
            "key": 29.9899997711,
            "doc_count": 70
          },
          {
            "key": 35.9900016785,
            "doc_count": 25
          },
          {
            "key": 39,
            "doc_count": 1
          },
          {
            "key": 39.9900016785,
            "doc_count": 28
          },
          {
            "key": 49.9900016785,
            "doc_count": 12
          },
          {
            "key": 59.9900016785,
            "doc_count": 3
          },
          {
            "key": 69.9899978638,
            "doc_count": 1
          }
        ]
      }
    }
  },
  "query": null,
  "checked": "{}"
}

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,我将数据类型从float更改为long,一切正常!