gpt4 book ai didi

elasticsearch search for elements with specified ID example(elasticsearch搜索具有指定ID的元素示例)

转载 作者:bug小助手 更新时间:2023-10-22 14:29:48 32 4
gpt4 key购买 nike



I want to find certain elements in my elastic search that have a given ID and I can't figure an easy way to do this.

我想在我的弹性搜索中找到某些具有给定ID的元素,但我想不出一个简单的方法来做到这一点。



I see http://www.elasticsearch.org/guide/reference/query-dsl/ids-query/ but can't for the life of me figure out how to structure a query to use it, or when I do toy around with es-head or curl I see errors like:

我明白了http://www.elasticsearch.org/guide/reference/query-dsl/ids-query/但我一辈子都不知道如何构造查询来使用它,或者当我摆弄es头或卷曲时,我会看到以下错误:



 Parse Failure [Failed to parse source [{"query":{"match_all":{}},"ids
{"values""1","4","100"]}}]]]; nested: SearchParseException[[dailyaggregates][4]:
query[ConstantScore(NotDeleted(*:*))],from[-1],size[-1]: Parse Failure [No parser for
element [ids]]]; }]


etc. Can anyone tell me how to set this up? Thanks.

等等。有人能告诉我如何设置吗?谢谢



edit: My attempt with that error was from es-head but similar errors through curl. I believe what I tried was some variant of this:

编辑:我的尝试是从es头,但类似的错误通过curl。我相信我尝试的是这种变体:



{
"query": {
"match_all": {}
},
"ids": {
"values": [
"100"
]
}
}

更多回答

Can you paste your curl command verbatim? The example you linked should work, so it's probably a question of where you strayed. :)

你能逐字粘贴你的curl命令吗?你链接的例子应该有效,所以这可能是你偏离了方向的问题。:)

Thanks for the reply. Posted what I'm using. I've tried moving it around, like inside the query and get similar errors...hopefully just something dumb.

谢谢你的回复。发布了我正在使用的内容。我试着移动它,就像在查询中一样,并得到类似的错误。。。希望只是一些愚蠢的东西。

优秀答案推荐

ids is a type of query, just like match, or match_all. So the format should be:

id是一种查询类型,就像match或match_all一样。因此,格式应该是:



{"query":{ "ids":{ "values": [ 100 ] } } }


You can alternatively do it as a filter, like so:

您也可以将其作为过滤器,如下所示:



{"filter":{ "query": {"ids":{ "values": [ 100 ] } } } }


TRY
GET /{YOUR_INDEX_NAME}/_doc/{ID}

尝试获取/{YOUR_INDEX_NAME}/_doc/{ID}


更多回答

Good man. Thanks very much. I find the English difficult to understand in the ES docs, so understand the terms has evaded me.

好人。非常感谢。我发现ES文档中的英语很难理解,所以我无法理解这些术语。

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

正如目前所写的,你的答案还不清楚。请编辑以添加其他详细信息,以帮助其他人了解这是如何解决所问问题的。你可以在帮助中心找到更多关于如何写出好答案的信息。

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com