gpt4 book ai didi

elasticsearch - Elasticsearch 突出显示不适用于自定义分析器/ token 生成器

转载 作者:行者123 更新时间:2023-12-02 22:37:22 24 4
gpt4 key购买 nike

我不知道为什么突出显示不起作用。该查询有效,但突出显示仅显示没有em标签的字段内容。这是我的设置和映射:

PUT wmsearch
{
"settings": {
"index.mapping.total_fields.limit": 2000,
"analysis": {
"analyzer": {
"custom": {
"type": "custom",
"tokenizer": "custom_token",
"filter": [
"lowercase"
]
},
"custom2": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase"
]
}
},
"tokenizer": {
"custom_token": {
"type": "ngram",
"min_gram": 3,
"max_gram": 10
}
}
}
},
"mappings": {
"doc": {
"properties": {
"document": {
"properties": {
"reference": {
"type": "text",
"analyzer": "custom"
}
}
},
"scope" : {
"type" : "nested",
"properties" : {
"level" : {
"type" : "integer"
},
"ancestors" : {
"type" : "keyword",
"index" : "true"
},
"value" : {
"type" : "keyword",
"index" : "true"
},
"order" : {
"type" : "integer"
}
}
}
}
}
}
}

这是我的查询:
GET wmsearch/_search
{
"query": {
"simple_query_string" : {
"fields": ["document.reference"],
"analyzer": "custom2",
"query" : "bloom"
}
},
"highlight" : {
"fields" : {
"document.reference" : {}
}
}
}

该查询确实返回正确的结果,并且结果中存在突出显示字段。但是,“bloom”周围没有em标签。相反,它仅显示整个字符串而根本没有标签。

是否有人在这里看到任何问题或可以提供帮助?

谢谢

最佳答案

我通过在我的document.reference映射中添加“index_options”:“offsets”来使其工作。

关于elasticsearch - Elasticsearch 突出显示不适用于自定义分析器/ token 生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46451224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com