问题描述
下面的查询是我想使用elasticsearch-dsl-py构造的,但是我不知道该怎么做。
GET /myindex/_search/
{
"query": {
"range": {
"int_field": {
"gte": "2455","lte": "2455"
}
}
}
}
select * from my_index where int_field >= 777 or int_field <= 779
使用elasticsearch-dsl-py,它与我所能接近的程度差不多,但是并不相同。
class MyIndex(Document):
int_field = Integer()
MyIndex.search().filter('range',int_field={"gte": 2454,"lte": 2456})
{“错误”:{ “根本原因”: [ { “ type”:“ query_shard_exception”, “ reason”:“无法创建查询:{\ n” range“:{\ n” int_field“:{\ n” from“:2454,\ n” to“:2456,\ n
“ include_lower”:false,\ n“ include_upper”:true,\ n
“ boost”:1.0 \ n} \ n} \ n}“, “ index_uuid”:“ HRdirs3LRnqO_5rbSjZi7A”, “ index”:“ myindex” } ], “ type”:“ search_phase_execution_exception”, “ reason”:“所有分片均失败”, “ phase”:“查询”, “分组”:是的, “ Failed_shards”:[ { “碎片”:0, “ index”:“ myindex”, “ node”:“ t-bkDruUSh61vUvKAlX2fw”, “原因”:{ “ type”:“ query_shard_exception”, “ reason”:“无法创建查询:{\ n” range“:{\ n” int_field“:{\ n” from“:2454,\ n” to“:2456,\ n
“ include_lower”:false,\ n“ include_upper”:true,\ n
“ boost”:1.0 \ n} \ n} \ n}“, “ index_uuid”:“ HRdirs3LRnqO_5rbSjZi7A”, “ index”:“ myindex”, “ caused_by”:{ “ type”:“ illegal_argument_exception”, “ reason”:“由于未索引字段[int_field],因此无法搜索。” } } } ]},“状态”:400}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)