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

index a @MultiField spring-data-elasticsearch. Internationalization purposes

我正在尝试为多语言目的索引多字段字符串属性 ("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.baprueba.catprueba.enprueba.gal 已编入索引,但您不会在源文档中看到它们。

您现在可以在查询中直接引用它们(映射中声明的分析器将按预期使用),您将获得预期的结果。例如,下面的查询应该 return id AVTxEfvBhgYXtMQTaKx1.

的文档
{
   "query": {
      "match": {
         "prueba.ba": "prueba"
      }
   }
}

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