我想为过滤器中的浮点数匹配精确值。在此过滤器中考虑myfloat
:
{
"filter" : { "bool" : { "must" : [
{ "match" : { "thing1" : "ABC" } },
{ "match" : { "thing2" : "SOMECODE" } },
{ "match" : { "myfloat" : 6490.1 } }
] } },
"weight" : 10
}
但是,似乎忽略了小数点后的所有内容。换句话说,myfloat为6490.5的记录将匹配。
有没有办法让它仅在完全匹配时才匹配?这些是美元值,因此不要超过两个小数。
编辑:
ES所说的是数据类型:
"myfloat" : {
"type" : "long"
},
最佳答案
您应该使用“term”进行完全匹配(https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-term-query.html)
所以你的过滤器将成为
{
"filter" : { "bool" : { "must" : [
{ "match" : { "thing1" : "ABC" } },
{ "match" : { "thing2" : "SOMECODE" } },
{ "term" : { "myfloat" : 6490.1 } }
] } },
"weight" : 10
}
关于elasticsearch - Elasticsearch匹配精确的浮点值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38754065/