【发布时间】:2021-07-23 17:12:32
【问题描述】:
我有一个可以工作的弹性搜索,但它真的太大了,它给了我太多与它无关的术语的结果。我正在寻找一种方法来完善这些结果。
在我搜索术语 music 时的一个假文本样本中,突出显示的术语是:must, much, alice, inside, patriotic, noticed
我认为ngram 对我没有帮助,但我认为我确实需要它来进行更好的搜索。
这是我的配置:
{
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "mySnowball", "myNgram"]
},
"default_search": {
"type": "custom",
"tokenizer": "standard",
"filter": ["standard", "lowercase", "mySnowball", "myNgram"]
}
},
"filter": {
"mySnowball": {
"type": "snowball",
"language": "English"
},
"myNgram": {
"type": "ngram",
"min_gram": 2,
"max_gram": 6
}
}
}
}
这是我的要求:
{
"query": {
"bool": {
"should": [{
"match": {
"content": "music"
}
}, {
"match": {
"url": "music"
}
}, {
"match": {
"h1": "music"
}
}, {
"match": {
"h2": "music"
}
}
],
"minimum_should_match": 1
}
},
"min_score": 8
}
我的文档很简单:
content => text,
url => text,
h1 => text,
h2 => text,
还有映射:
$configMapping = [
'content' => ['type' => 'text', 'boost' => 6],
'url' => ['type' => 'text', 'boost' => 6],
'h1' => ['type' => 'text', 'boost' => 9],
'h2' => ['type' => 'text', 'boost' => 7]
]
我欢迎任何能让我获得一致结果的修改。
【问题讨论】:
-
能否分享一些示例索引数据和预期的搜索结果?
标签: php elasticsearch elastica