我的彈性資料庫中有這個檔案。我正在使用這個包 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結果。為什么?是否可以獲取該資料。issue關鍵字出現在第一個集合中,為什么不選擇?
[
{
"_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"
}
}
]
如何搜索關鍵字?任何關鍵字匹配。我需要挑選整個系列
uj5u.com熱心網友回復:
如果您只想匹配查詢中的某些單詞,則可以使用match querywith operatorset to or。
{
"query": {
"match": {
"title": {
"query": "i have issues",
"operator": "or"
}
}
}
}
更新
要運行您在評論中提到的查詢,您可以使用match_bool_prefix查詢。
{
"query": {
"match_bool_prefix": {
"title": {
"query": "i have issu"
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/453277.html
標籤:javascript 节点.js 弹性搜索
