简体   繁体   English

ElasticSearch Facets条款查询浮点精度

[英]ElasticSearch Facets Terms Query float precision

I have some problems with the facets terms query (with ElasticSearch 1.7.0), all float values are right stored in the database and in the elasticsearch bulk too, but when I request the data I get the values like that "2.99000000954". 我在facets字词查询(使用ElasticSearch 1.7.0)时遇到一些问题,所有浮点值也都正确存储在数据库中,并且也大量存储在Elasticsearch中,但是当我请求数据时,我得到的值类似于“ 2.99000000954”。

The strange thing is that when I put my request with "2.99000000954", the engine found the good Article related with this data, the article with the "2.99" value. 奇怪的是,当我用“ 2.99000000954”发出请求时,引擎找到了与此数据相关的好文章,即具有“ 2.99”值的文章。

Please have a look on the below codes files and the curl call request: 请查看以下代码文件和curl调用请求:

Mapping (from _plugin/head) 映射(来自_plugin / head)

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

elastic_bulk_Article_en_XXX.json0 elastic_bulk_Article_en_XXX.json0

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

The curl call 卷发电话

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}'

The curl call results 卷曲调用结果

{
  "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": "{}"
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM