是否有可能检查给定索引中是否存在documentId列表并在弹性搜索中键入?(Is it possible check whether a list of documentIds is present

编程入门 行业动态 更新时间:2024-10-23 20:23:55
是否有可能检查给定索引中是否存在documentId列表并在弹性搜索中键入?(Is it possible check whether a list of documentIds is present in given Index and Type in Elastic Search?)

我在弹性搜索中有一个场景。 我有一个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"]}'

更多推荐

本文发布于:2023-07-28 01:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1298285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有可能   并在   是否存在   弹性   索引

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!