我需要从字段中获取小于50的值" cost"所以我该怎么做?`
{
"query" :
{
"field" :"cost",
{
"lt" : 50
}
}
}
答案 0 :(得分:3)
使用范围查询:
{
"query": {
"range": {
"cost": {
"lt": 50
}
}
}
}
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
或者您可以使用范围过滤器(结果将被缓存)。
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"range": {
"cost": {
"lt": 50
}
}
}
}
}
}
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-range-filter.html