gpt4 book ai didi

java - 索引@MultiField spring-data-elasticsearch。国际化目的

转载 作者:搜寻专家 更新时间:2023-11-01 03:34:00 26 4
gpt4 key购买 nike

我正在尝试为多语言目的索引多字段字符串属性(“prueba”)。我的映射正在使用注释

@MultiField(
mainField = @Field(type = FieldType.String, store = true),
otherFields = {
@NestedField(dotSuffix = "cat", type = FieldType.String, store = true, indexAnalyzer = "catalan", searchAnalyzer = "catalan" ),
@NestedField(dotSuffix = "ba", type = FieldType.String, store = true, indexAnalyzer = "basque", searchAnalyzer = "basque"),
@NestedField(dotSuffix = "gal", type = FieldType.String, store = true, indexAnalyzer = "galician", searchAnalyzer = "galician"),
@NestedField(dotSuffix = "en", type = FieldType.String, store = true, indexAnalyzer = "english", searchAnalyzer = "english")}
)
protected String prueba;

结果映射是:

,
"prueba": {
"type": "string",
"store": true,
"fields": {
"prueba.ba": {
"type": "string",
"store": true,
"analyzer": "basque"
},
"prueba.cat": {
"type": "string",
"store": true,
"analyzer": "catalan"
},
"prueba.en": {
"type": "string",
"store": true,
"analyzer": "english"
},
"prueba.gal": {
"type": "string",
"store": true,
"analyzer": "galician"
}
}
},

所以,我索引了我的对象,但结果只是...`

IndexQuery query = new IndexQuery();
query.setObject(itemTransparencia);
query.setType(subportal);

String id = this.elasticsearchOperations.index(query);

GET /item_transparencia/432/_search

{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "item_transparencia",
"_type": "432",
"_id": "AVTxEfvBhgYXtMQTaKx1",
"_score": 1,
"_source": {
"subportal": "432",
"titulo": null,
"prueba": "prueba la tarta de mi casa",
"subTitulo": null,
"descripcion": null,
"fechaIndexado": "2016-05-

我只得到“prueba”:“prueba la tarta de mi casa”

-任何人都可以帮助我了解如何从字段“prueba”中索引或获取嵌套字段吗?-indexAnalyzer = "catalan", searchAnalyzer = "catalan"是否帮助我自动索引到另一种语言?

非常感谢!

最佳答案

多字段 prueba.ba, prueba.cat, prueba.en, prueba.gal已编入索引,但您不会在源文档中看到它们。

您现在可以在查询中直接引用它们(映射中声明的分析器将按预期使用),您将获得预期的结果。例如,以下查询应返回 ID 为 AVTxEfvBhgYXtMQTaKx1 的文档。

{
"query": {
"match": {
"prueba.ba": "prueba"
}
}
}

但是,请注意,在字段上设置语言分析器不会将该字段的内容翻译成该分析器的语言,您需要自己完成。

关于java - 索引@MultiField spring-data-elasticsearch。国际化目的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37478900/

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