2017-09-27 5 views
0

にアナライザを適用します。は、私は、このアナライザを持っているオブジェクトフィールド

{ 
    "index": { 
    "number_of_shards": 1, 
    "analysis": { 
     "filter": { 
     "word_joiner": { 
      "type": "word_delimiter", 
      "catenate_all": true, 
      "preserve_original": true 
     } 
     }, 
     "analyzer": { 
     "word_join_analyzer": { 
      "type": "custom", 
      "filter": [ 
      "word_joiner" 
      ], 
      "tokenizer": "keyword" 
     } 
     } 
    } 
    } 
} 

私はこの場でそれを適用します。

@Field(type = FieldType.Object, analyzer = "word_join_analyzer") 
private Description description; 

そして、ここでは説明のクラスです:

public class Description { 

     @JsonProperty("localizedDescriptions") 
     private Map<String, String> descriptions = new HashMap<>(); 
} 

これは、このフィールドの結果のElasticsearchマッピング:

{ 
    "description":{ 
     "properties":{ 
     "localizedDescriptions":{ 
      "properties":{ 
       "en":{ 
        "type":"string" 
       }, 
       "fr":{ 
        "type":"string" 
       }, 
       "it":{ 
        "type":"string" 
       } 
      } 
     } 
     } 
    } 
} 

ご覧のように、アニリンザーはまったく適用されません。これは文字列フィールドでうまく動作しますが、Object型では苦労します。何か案は?
ありがとうございます!

EDIT:私は動的マッピングを使用してみました:

{ 
    "iam":{ 
    "properties":{ 
     "dynamic_templates":[ 
     { 
      "localized_strings_values":{ 
      "path_match":"description.localizedDescriptions.*", 
      "mapping":{ 
       "type":"string", 
       "analyzer":"word_join_analyzer" 
      } 
      } 
     } 
     ] 
    } 
    } 
} 

をしかし、私はこのエラーを持っている:

Expected map for property [fields] on field [dynamic_templates] but got a class java.lang.String 

は、なぜ私はこのエラーが出るのですか?

+0

アナライザーをオブジェクトフィールドに適用することはできません。必要なすべての文字列フィールドに明示的に追加する必要があります。 – Val

+0

この場合、どうすればいいですか?それは地図です。 – Anna

+0

アナライザーを説明フィールドに直接入力しようとしましたか? – Val

答えて

0

Finalyがこれを解決しました。これは正しいマッピングです:

{ 
    "cake": { 
    "dynamic_templates": [ 
     { 
     "localized_descriptions": { 
      "path_match": "description.localizedDescriptions.*", 
      "mapping": { 
      "type": "string", 
      "analyzer": "word_join_analyzer" 
      } 
     } 
     } 
    ] 
    } 
} 
関連する問題