我在弹性搜索中有一个场景。 我有一个documentIds列表,我必须检查所有documentId是否存在于特定的索引和类型中(将提供)。 我需要知道弹性搜索查询方法是否可行。 如果是这样,你能用一个例子解释一下吗?
另外,假设给出了索引中不存在的documentId,是否可以检索该documentId?
我听说过脚本和scriptParams但我不知道它。 有可能使用它吗? Plz解释一个例子或提供一个合适的链接。
提前致谢。
I have a scenario in Elastic Search. I have a list of documentIds which I have to check whether all documentId's are present in a particular index and type(which will be provided). I need to know is that possible in Elastic Search querying methodology. If so , can you plz explain with an example ?
Additionally, supposing a documentId which is not present in the index is given, is it possible to retrieve that documentId ?
I have heard about script and scriptParams but I am unaware of it. Is it possible using that? Plz explain with an example or provide a suitable link.
Thanks in advance.
最满意答案
可能最简单的方法是尝试使用multi-get API检索所有文档:
curl -XGET "http://localhost:9200/myindex/mytype/_mget" -d' { "ids": ["good_id", "missing_id"]}'这将返回所有文档的数组。 如果未找到任何doc,则该元素的exists将设置为false 。 (在v1.0中, exists已重命名为found )。
如果您不想检索文档正文,请在查询字符串中将fields参数设置为nothing:
curl -XGET "http://localhost:9200/myindex/mytype/_mget?fields=" -d' { "ids": ["good_id", "missing_id"]}'Probably the easiest way to do this would be to just try to retrieve all of the documents, using the multi-get API:
curl -XGET "http://localhost:9200/myindex/mytype/_mget" -d' { "ids": ["good_id", "missing_id"]}'This will return an array of all docs. If any doc was not found, then exists will be set to false for that element. (In v1.0, exists has been renamed to found).
If you don't want to retrieve the body of the document, then set the fields parameter to nothing in the query string:
curl -XGET "http://localhost:9200/myindex/mytype/_mget?fields=" -d' { "ids": ["good_id", "missing_id"]}'更多推荐
发布评论