0

I am trying to create mappings for my indext in JEST using the Document.Builder class from ElasticSearch. I have followed the example specified bellow in the readme for JEST but it doesn't seem to work.

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);

For the version of ES i am using(v2.3.0) it the DocumentMapper.Builder class doesn't seem to contain the same specified parameters in the Builder constructor that was stated in the example. Can someone point me to an update if there exists any?

Nkosi
  • 235,767
  • 35
  • 427
  • 472
enwafor
  • 101
  • 1
  • 8

1 Answers1

0

The DocumentMapper.Builder constructor has changed for ElasticSearch version 2.3.0, the new constructor is like:

public Builder(RootObjectMapper.Builder builder, MapperService mapperService)

So you can use this new constructor or you may use the JSON strings builder with something like the example as:

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

Carlos Saltos
  • 1,385
  • 15
  • 15