嗨,有人能帮我理解elasticsearch如何评估标记的相关性吗?我有一个Map看起来像
{
"settings": {
"index": {
"refresh_interval": "-1",
"number_of_shards": "4",
"analysis": {
"filter": {
"stopwords_SK": {
"ignore_case": "true",
"type": "stop",
"stopwords_path": "stopwords/slovak.txt"
},
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": "2",
"max_gram": "20"
}
},
"analyzer": {
"autocomplete": {
"filter": [
"stopwords_SK",
"lowercase",
"stopwords_SK",
"autocomplete_filter"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1"
}
},
"mappings": {
"doc": {
"dynamic": "strict",
"properties": {
"nn": {
"type": "text",
"fielddata": true,
"fields": {
"raw": {
"type": "keyword"
}
},
"boost": 10,
"analyzer": "autocomplete"
}
}
}
}
}
nn字段通过标准标记化器进行标记化。下一个简单的查询运行良好,并返回相关结果,如“softone sro”、“softec sro”。。。
{
"_source": [
"nn",
"nazov"
],
"size": 10,
"query": {
"bool": {
"must": [
{
"match": {
"nn": "softo"
}
}
]
}
}
}
但是如果我需要在查询中添加should条件,它绝对不会返回任何相关的结果,并且缺少以前最相关的结果,如“sofone”或“softex”。它返回例如“zo soz kovo zts nova as zts elektronika as”或“agentura socialnych sluzieb ass no”。。。这里是应该查询
{
"_source": [
"nn",
"nazov"
],
"size": 10,
"query": {
"bool": {
"must": [
{
"match": {
"nn": "softo"
}
}
],
"should": [
{
"match": {
"nn": "as"
}
},
{
"match": {
"nn": "sro"
}
}
]
}
}
}
为什么查询结果会缺少第一次查询中最相关的“sofone”和“softex”项?我认为相关性是基于标记长度的,这意味着“sotf”标记比“so”标记更相关。谢谢。
暂无答案!
目前还没有任何答案,快来回答吧!