【发布时间】:2018-12-18 14:02:40
【问题描述】:
我有一个问题,希望有人可以帮助我。
我有一个使用匹配查询进行搜索的简单示例
"query": {
"match": {
"filterValues": "ordner ohne griffloch"
}
}
我正好得到两个命中:
"hits" : [
{
"_index" : "filters",
"_type" : "filter",
"_id" : "F-114150068-1170182",
"_score" : 5.420828,
"_source" : {
"filterValues" : [
"Ja",
"Griffloch vorhanden",
"Griffloch",
"mit Griffloch"
]
},
"highlight" : {
"filterValues" : [
"<em>Griffloch</em>"
]
}
},
{
"_index" : "filters",
"_type" : "filter",
"_id" : "F-114150069-1170182",
"_score" : 4.452639,
"_source" : {
"filterValues" : [
"ohne Griffloch",
"kein Griffloch",
"Nein"
]
},
"highlight" : {
"filterValues" : [
"<em>ohne Griffloch</em>"
]
}
}
]
我的问题是:我想找到第二个命中“ohne Griffloch”作为第一个(更好的分数),因为它匹配更多的单词。但我发现第一个得分更高,我想是因为它包含更多“Griffloch”。
我不能使用术语查询,因为当查询包含其他单词(此处为:“ordner”)时,我将找不到任何内容,因为它与任何内容都不完全匹配。
有什么想法吗?
谢谢!
有关索引配置的信息:
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase"
]
},
"lowercase_shingle": {
"tokenizer": "whitespace",
"filter": [
"lowercase",
"my_shingle"
]
}
},
"filter": {
"my_shingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 4
}
}
}
},
"mappings": {
"filter": {
"properties": {
"filterValueId": {
"type": "long"
},
"filterValues": {
"type": "text",
"position_increment_gap": 100,
"analyzer": "default",
"search_analyzer": "lowercase_shingle"
},
"categoryId": {
"type": "long"
}
}
}
}
【问题讨论】:
-
请分享您的完整
query结构 -
您希望采用哪种结构?我有我输入的所有内容,除了我删除的字段的突出显示。
标签: elasticsearch