ES的Mapping映射字段
"title": {
"type": "text",
"analyzer": "ik_max_word",
"copy_to": [
"fullText"
]
},
"titleZh": {
"type": "text",
"analyzer": "ik_max_word",
"copy_to": [
"fullText"
]
},
"content": {
"type": "text",
"analyzer": "ik_max_word",
"copy_to": [
"fullText"
],
"term_vector": "with_positions_offsets"
},
"contentZh": {
"type": "text",
"analyzer": "ik_max_word",
"copy_to": [
"fullText"
],
"term_vector": "with_positions_offsets"
}
检索查询语法
{
"bool" : {
"should" : [
{
"match" : {
"title" : {
"query" : "8500万",
"operator" : "OR",
"analyzer" : "ik_smart",
"prefix_length" : 0,
"max_expansions" : 5,
"minimum_should_match" : "1",
"fuzzy_transpositions" : false,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : false,
"boost" : 1.0
}
}
},
{
"match_phrase" : {
"title" : {
"query" : "8500万",
"analyzer" : "ik_smart",
"slop" : 5,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
},
{
"match" : {
"titleZh" : {
"query" : "8500万",
"operator" : "OR",
"analyzer" : "ik_smart",
"prefix_length" : 0,
"max_expansions" : 5,
"minimum_should_match" : "1",
"fuzzy_transpositions" : false,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : false,
"boost" : 1.0
}
}
},
{
"match_phrase" : {
"titleZh" : {
"query" : "8500万",
"analyzer" : "ik_smart",
"slop" : 5,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
},
{
"match" : {
"content" : {
"query" : "8500万",
"operator" : "OR",
"analyzer" : "ik_smart",
"prefix_length" : 0,
"max_expansions" : 5,
"minimum_should_match" : "1",
"fuzzy_transpositions" : false,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : false,
"boost" : 1.0
}
}
},
{
"match_phrase" : {
"content" : {
"query" : "8500万",
"analyzer" : "ik_smart",
"slop" : 5,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
},
{
"match" : {
"contentZh" : {
"query" : "8500万",
"operator" : "OR",
"analyzer" : "ik_smart",
"prefix_length" : 0,
"max_expansions" : 5,
"minimum_should_match" : "1",
"fuzzy_transpositions" : false,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : false,
"boost" : 1.0
}
}
},
{
"match_phrase" : {
"contentZh" : {
"query" : "8500万",
"analyzer" : "ik_smart",
"slop" : 5,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
检索结果
问题
- 8500万没有高亮
- 我知道是分词原因,但如何在不改变分词方式的情况能让检索内容都高亮上
- 相关性排序
- 如何提高权重,以检索匹配度来排序
- 检索优化
- 这是个另外的问题,我有个场景是用标题全部文本去检索,但是检索的很慢,还会基于检索内容匹配到很多杂项,如何提高精准度,如果全文匹配,只检索到个别的文档?