gpt4 book ai didi

elasticsearch - elastic4s 搜索 id

转载 作者:行者123 更新时间:2023-12-02 22:22:57 25 4
gpt4 key购买 nike

关于搜索_id字段的两个问题:

  1. 我想使用 elastic4s dsl 查找特定 ID 是否存在。此查询 elasticsearch API 的等效项:

    curl -XGET ' http://localhost:9200/indexName/indexType/_search/exists?q=_id:foo '

我试着做这样的事情:

 client execute search(indexName / indexType) query ("_id", "foo")

但这会产生 SearchDefinitionisExists 无法检查它

  1. 我想获取所有的_id到目前为止,我得到了这个解决方案,但我不确定这是不是惯用的方法

    client.execute(search(indexName/indexType) query "id").map(.ids)

最佳答案

您可以使用 IDs 查询 https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html#query-dsl-ids-query 查询 ID

 search("electronics" / "phone").query(idsQuery("foo"))

关于elasticsearch - elastic4s 搜索 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45421564/

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