2017-10-12 12 views
1

インデックスのマッピングのアナライザを変更しようとしています。私はシンプルなText型のプロパティのためにそれを行う方法を理解していますが、.NETでは(NESTのAutoMap()関数を使用して)マッピングを作成するクラスはDictionary<object, object>タイプで、次のようなインデックスマッピングを作成します:ElasticSearch - ディクショナリ<オブジェクト、オブジェクト>のホワイトスペースアナライザ

"attributes": { 
    "properties": { 
    "comparer": { 
     "type": "object" 
    }, 
    "count": { 
     "type": "integer" 
    }, 
    "item": { 
     "type": "object" 
    }, 
    "keys": { 
     "properties": { 
     "count": { 
      "type": "integer" 
     } 
     } 
    }, 
    "values": { 
     "properties": { 
     "count": { 
      "type": "integer" 
     } 
     } 
    } 
    } 
}, 

私は以下のようなメッセージになっています上記のマッピング内のフィールドのいずれかのアナライザーを変更しようとしている:

{ 
    "error": { 
    "root_cause": [ 
     { 
     "type": "illegal_argument_exception", 
     "reason": "mapper [attributes.Title] of different type, current_type [text], merged_type [ObjectMapper]" 
     } 
    ], 
    "type": "illegal_argument_exception", 
    "reason": "mapper [attributes.Title] of different type, current_type [text], merged_type [ObjectMapper]" 
    }, 
    "status": 400 
} 

を私は何かにアナライザを置くことができないエラーメッセージから想定していますDictionary<object, object>として一般的ですが、私はうまくいくアプローチを見つける必要がありますか? (それが可能であると仮定して)

+0

'辞典<オブジェクト、オブジェクト>'ややElasticsearchでのマッピングとのインピーダンス不整合である:) –

答えて

0

次のNESTオート&手動の流暢なコードは私のために上記の問題を解決しました。私は、インデックスを作成しないようにしたDictionary<object, object>を理解しようとするElastic Searchに問題があると考えています。 Object<object>を使用すると、トリックでした:

elasticClient.CreateIndex("YOURINDEX", i => i 
    .Mappings(ms => ms 
     .Map<YOURTYPE>(m => m 
      .AutoMap() 
      .Properties(props => props 
       .Object<object>(o => o 
        .Name(x => x.Attributes) 
        .Properties(pprops => pprops 
         .Text(ps => ps 
          .Name(AttributeType.Title.ToString().ToLower()) 
          .Analyzer("whitespace") 
          .Fielddata(true) 
          .Fields(f => f 
           .Keyword(k => k 
            .Name("keyword") 
           ) 
          ) 
         ) 
        ) 
       ) 
      ) 
     ) 
    ) 
); 
関連する問題