在JEST中使用ES Document.Builder类创建映射

时间:2016-06-30 18:16:41

标签: elasticsearch jest

我正在尝试使用ElasticSearch中的Document.Builder类在JEST中为我的indext创建映射。我已经按照JEST自述文件中指定的示例进行了操作,但它似乎无法正常工作。

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构造函数中的相同指定参数。如果有任何人可以指点我更新吗?

1 个答案:

答案 0 :(得分:0)

DocumentMapper.Builder构造函数已更改为ElasticSearch版本2.3.0,新构造函数如下:

UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 110)]; UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(200,8,200,30)]; navLabel.text = @"My Text"; navLabel.textColor = [UIColor redColor]; [navLabel setBackgroundColor:[UIColor clearColor]]; UILabel *navLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(200,navLabel.frame.origin.y + navLabel.frame.size.height + 5,200,30)]; navLabel1.text = @"My Text1"; navLabel1.textColor = [UIColor redColor]; [navLabel1 setBackgroundColor:[UIColor clearColor]]; UILabel *navLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(200,navLabel1.frame.origin.y + navLabel1.frame.size.height + 5,200,30)]; navLabel2.text = @"My Text2"; navLabel2.textColor = [UIColor redColor]; [navLabel2 setBackgroundColor:[UIColor clearColor]]; [naviBarObj addSubview:navLabel]; [naviBarObj addSubview:navLabel1]; [naviBarObj addSubview:navLabel2]; [self.view addSubview:naviBarObj];

因此,您可以使用此新构造函数,或者您可以使用JSON字符串构建器,例如:

public Builder(RootObjectMapper.Builder builder, MapperService mapperService)