0

ElasticSearch の Document.Builder クラスを使用して、JEST で indext のマッピングを作成しようとしています。JEST の readme で以下に指定されている例に従いましたが、うまくいかないようです。

RootObjectMapper.Builder rootObjectMapperBuilder = new RootObjectMapper.Builder("my_mapping_name").add(
    new StringFieldMapper.Builder("message").store(true));    

DocumentMapper documentMapper = new DocumentMapper.Builder("my_index", null, rootObjectMapperBuilder).build(null);
String expectedMappingSource = documentMapper.mappingSource().toString();
PutMapping putMapping = new PutMapping.Builder(
    "my_index",
    "my_type",
    expectedMappingSource).build();

client.execute(putMapping);

私が使用している ES のバージョン (v2.3.0) では、DocumentMapper.Builder クラスには、例で述べたものと同じ指定されたパラメーターが Builder コンストラクターに含まれていないようです。更新がある場合、誰かが更新を教えてもらえますか?

4

1 に答える 1

0

DocumentMapper.Builder コンストラクターは ElasticSearch バージョン 2.3.0 用に変更されました。新しいコンストラクターは次のようになります。

public Builder(RootObjectMapper.Builder builder, MapperService mapperService)

したがって、この新しいコンストラクターを使用するか、次のような例で JSON 文字列ビルダーを使用できます。

PutMapping putMapping = new PutMapping.Builder( "my_index", "my_type", "{ \"document\" : { \"properties\" : { \"message\" : {\"type\" : \"string\", \"store\" : \"yes\"} } } }" ).build();

于 2016-09-22T10:48:06.420 に答える