您应该在查询中添加短语匹配的增强。因此,在多个filterValues中找到所有查询项的文档自然会得到增强。
但你得小心这个怪癖(
see here, official doc
)
我不知道是怎么回事(也许你身上有原力),但你的地图已经对了
position_increment_gap
但是你应该删除设置
search_analyzer:“小写_shingle”
因为在你的背景下似乎有点奇怪。
然后我们在匹配短语上加上boost
{
"query": {
"bool": {
"must": [
{
"match": {
"filterValues": "ordner ohne griffloch"
}
}
],
should: [
{
"match_phrase": {
"filterValues": {
"query": "ordner ohne griffloch",
"slop": 10
}
}
}
]
}
}
}
希望能成功!
评论后编辑:
如果更改映射,以便在索引时使用shingle_分析器添加子字段
"mappings": {
"filter": {
"properties": {
"filterValueId": {
"type": "long"
},
"filterValues": {
"type": "text",
"position_increment_gap": 100,
"analyzer": "default",
"search_analyzer": "lowercase_shingle",
"fields": {
"shingled": {
"type": "text",
"analyzer": "lowercase_shingle",
}
}
},
"categoryId": {
"type": "long"
}
}
}
}
然后,您可以使用此查询在shingled子字段上添加一个boost
{
"query": {
"bool": {
"must": [
{
"match": {
"filterValues": "ordner ohne griffloch"
}
}
],
should: [
{
"match": {
"filterValues.shingled": "ordner ohne griffloch"
}
}
]
}
}
}
在你的例子中,第二个博士而不是第一个博士