gpt4 book ai didi

elasticsearch - ElasticSearch 7.6.3 Java HighLevel Rest Client:跨多个字段自动建议-如何实现

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

我们有一个包含以下字段的索引,并且需要通过在索引中所有文本和关键字映射字段中搜索数据来向用户提供自动建议

{


"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
}
},

"mappings": {
"properties": {
"id": {
"type": "text"
},
"title": {
"type": "text"
},
"date": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
},
"subject": {
"type": "text"
},
"title_suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
},
"subject_suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50

}
"fieldOr": {
"type": "text"
},
"fieldsTa": {
"type": "text"
},
"notes": {
"type": "text"
},
"fileDocs": {
"type": "nested",
"properties": {
"fileName": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "standard"
},
"fileContent": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "standard"
},
"docType": {
"type": "keyword"
},
"opinionId": {
"type": "integer"
}
}
},
"fileMeta": {
"type": "nested",
"properties": {
"url": {
"type": "text"
},
"name": {
"type": "text"
}
}
}
}
}
}

我尝试了“完成建议”,但它可用于1个字段。我已经在索引中创建了2个带有* -suggest的字段,并尝试使用completenessSuggest创建建议
SuggestBuilders.completionSuggestion("my_index_suggest").text(input);

但是它仅支持1个字段。我将ES 7.6.3和Java HighLevel Rest Client一起使用,它可用于1个字段。我需要做哪些更改才能支持多个 Realm 。是否可以通过JSON搜索?如果是,那么我可以使用Xcontentbuilder创建一个json并执行自动建议?

最佳答案

使用copy_to并将所有需要的字段复制到一个字段,并在其上执行建议。

来自copy_to文档的示例是,

PUT my_index
{
"mappings": {
"properties": {
"first_name": {
"type": "text",
"copy_to": "full_name"
},
"last_name": {
"type": "text",
"copy_to": "full_name"
},
"full_name": {
"type": "text"
}
}
}
}

关于elasticsearch - ElasticSearch 7.6.3 Java HighLevel Rest Client:跨多个字段自动建议-如何实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60397369/

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