gpt4 book ai didi

elasticsearch - Elasticsearch-如何在所有索引和文档中搜索词的一部分

转载 作者:行者123 更新时间:2023-12-03 01:20:39 25 4
gpt4 key购买 nike

我想进行这样的搜索:

  • 例如,当我输入“Desc”时,我想获取包含“Desc”的所有内容,并且不区分大小写。我不想包括索引名称或文档,而是希望它搜索所有内容。

  • 我试过了,但是效果不是很好。

    GET /_search 
    {
    "query":
    { "query_string":
    {
    "query": "Test*"
    }
    }
    }

    最佳答案

    尝试使用通配符搜索。确保您要搜索的字段是text字段。

    {
    "query": {
    "query_string" : {
    "query" : "*desc*"
    }
    }
    }

    如果要使用所有索引,可以像这样查询
    curl -XGET 'http://localhost:9200/index1,index2/_search

    PS:从性能 Angular 来看,这不是一个好主意,因为它会搜索索引中的所有字段。或者,您可以在查询字符串中使用 default_field并指定该字段。

    关于elasticsearch - Elasticsearch-如何在所有索引和文档中搜索词的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60304472/

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