我正在寻找一种方法来返回_id小于给定_id的所有文档,但是我没有检索到。我正在尝试的查询是:
curl -XPOST "http://localhost:9200/smartjn/feed_details/_search" -d' {"query":{"range":{"uid":{"gte":"56f43c0344fc86e73b1170b0"}}}}'
This gives me result as:
{"took":21,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
但是,我可以看到10K记录中有_id>我上面提到的。我知道如何实现这一目标。
在MongoDB中我使用
'_id' => [
'$lt' =>
new MongoDB\BSON\ObjectId($_GET['lastid'])
]
实现同样的目标。
答案 0 :(得分:0)
当我执行测试时,我获得了成功的结果。你可以发布字段uid的索引映射吗? localhost:9200/smartjn/_mapping/feed_details/field/uid
pancake$ curl -XGET localhost:9200/test_index/test_type2/_search -d '{"query":{"range":{"uid":{"gte":"56f43c0344fc86e73b1170b0"}}}}'
{"took":11,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},"hits":
{"total":4,"max_score":1.0,"hits": [
{"_index":"test_index","_type":"test_type2","_id":"AVeLab8ILs6L_WBjvpfv","_score":1.0,"_source":{"uid":"56f43c0344fc86e73b1170b0"}},
{"_index":"test_index","_type":"test_type2","_id":"AVeLadPoLs6L_WBjvpfx","_score":1.0,"_source":{"uid":"56f43c0344fc86e73b1170b2"}},
{"_index":"test_index","_type":"test_type2","_id":"AVeLadp4Ls6L_WBjvpfy","_score":1.0,"_source":{"uid":"56f43c0344fc86e73b1170b3"}},
{"_index":"test_index","_type":"test_type2","_id":"AVeLacwhLs6L_WBjvpfw","_score":1.0,"_source":{"uid":"56f43c0344fc86e73b1170b1"}}
]}}
快速问题,您问过"我正在寻找一种方法来返回_id 小于给定_id但仍未能检索到的所有文档。"然后您使用 gte (大于或等于)查询。你在寻找什么结果?