如果任何搜索关键字匹配,如何获取项目?

how to fetch items if any search keyword matched?

我的 elastic 中有这个文件 DB.I 我正在使用这个包 https://www.npmjs.com/package/@elastic/elasticsearch

我正在搜索 title

我就是这样做的

const result= await client.search({
      index: 'products',
      "query": {
        "bool": {
          "should": [
            {
              "wildcard": { "title": "*" + search + "*" }
            }
          ],
          "minimum_should_match": 1
        }
      }

当我搜索“标题”时 issue。它给了我 一个结果 但是当我搜索时 i have issue 。它给出零或 0 result.why ?是否可以获取该数据。issue 关键字出现在第一个 collection 为什么它没有被采摘?

[
  {
    "_index": "products",
    "_id": "wZRh3n8Bs9qQzO6fvTTS",
    "_score": 1.0,
    "_source": {
      "title": "laptop issues",
      "description": "laptop have issue present in according"
    }
  },
  {
    "_index": "products",
    "_id": "wpRh3n8Bs9qQzO6fvzQM",
    "_score": 1.0,
    "_source": {
      "title": "buy mobile",
      "description": "mobile is in Rs 250"
    }
  },
  {
    "_index": "products",
    "_id": "w5Rh3n8Bs9qQzO6fvzTz",
    "_score": 1.0,
    "_source": {
      "title": "laptop payment",
      "description": "laptop payment is given in any way"
    }
  }
]

如何搜索关键字?任何关键字匹配。我需要选择整个系列

如果您只想匹配查询中的部分单词,则可以使用 match query 并将 operator 设置为 or

{
  "query": {
    "match": {
      "title": {
        "query": "i have issues",
        "operator": "or"
      }
    }
  }
}

更新

对于运行您在评论中提到的查询,您可以使用match_bool_prefix查询。

{
  "query": {
    "match_bool_prefix": {
      "title": {
        "query": "i have issu"
      }
    }
  }
}