gpt4 book ai didi

elasticsearch - Elasticsearch 嵌套对象自动完成

转载 作者:行者123 更新时间:2023-12-02 23:16:04 25 4
gpt4 key购买 nike

我正在尝试将自动完成功能添加到在 flex 搜索中创建的嵌套对象中。

我设置的映射设置:

"mappings": {
"doc": {
"object": {
"type": "nested",
"properties": {
"author": {
"type": "text",
"analyzer": "hebrew"
},
"content": {
"type": "text",
"analyzer": "hebrew"
},
"title": {
"type": "text",
"analyzer": "hebrew"
},
"suggest" : { "type": "completion"}
}
}
}
}

我使用的是嵌套对象,因为我还使用fscrawler将json文档添加到索引中。

我使用以下查询:
{
"suggest": {
"suggester" : {
"prefix" : "test",
"completion" : {
"field" : "object.suggest"
}
}
}
}

但是问题是无论键入什么我都没有结果。

我是否正确设置了映射?还是查询错误?

最佳答案

最后对我有用的是为每个要与我一起使用自动建议的对象字段使用一个建议子字段,例如,如果我想对“作者”和“标题”字段使用自动建议,则可以使用:

"mappings": {
"doc": {
"object": {
"type": "nested",
"properties": {
"author": {
"type": "text",
"analyzer": "hebrew",
"fields": {
"exact": {
"type": "text",
"analyzer": "hebrew_exact"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": false,
"preserve_position_increments": true,
"max_input_length": 50
}
}
},
"content": {
"type": "text",
"analyzer": "hebrew_exact"
},
"title": {
"type": "text",
"analyzer": "hebrew",
"fields": {
"exact": {
"type": "text",
"analyzer": "hebrew_exact"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": false,
"preserve_position_increments": true,
"max_input_length": 50
}
}
}
}
}
}

要使用它,我将使用文档中的建议程序搜索“object.title.suggest”字段。

关于elasticsearch - Elasticsearch 嵌套对象自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54787993/

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