0

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".

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.

Please have a look on the below codes files and the curl call request:

Mapping (from _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"
  ],
}

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": "{}"
}
keupsonite
  • 399
  • 3
  • 15
  • This answer might help: http://stackoverflow.com/questions/38952262/elasticsearch-max-length-of-mapping-type-long/38952540#38952540 – Val Jan 18 '17 at 09:13
  • @Val Thank you for your comment. Sadly, the solution can't work for me, the value in the elasticsearch bulk file is already stored as string data type. – keupsonite Jan 18 '17 at 10:11
  • What I was merely hinting at is that you're suffering from rounding issues, which are common with float – Val Jan 18 '17 at 10:14
  • @Val No problem, thank you anyway :) – keupsonite Jan 18 '17 at 10:16

1 Answers1

0

I've found the solution, I changed the datatype from float to long and everything works!

keupsonite
  • 399
  • 3
  • 15