Replacing BaseQueryBuilder with QueryBuilder issue


(Paul Alles) #1

im upgrading our java client from 0.60.2 to 2.2.0. in old version i found BaseQueryBuilder and related functions and i could replace most of the code with QueryBuilder. now im confused about this code segment.

BaseQueryBuilder fq = new BaseQueryBuilder()
{
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException
{
builder.startObject("multi_match");
builder.field("query", matchquery);
builder.field("fields", new String[] { k });
builder.field("type", "phrase");
builder.field("operator", "and");
builder.endObject();
}
};

how can i replace above code segment with suitable function?

whole code is
BoolQueryBuilder query = QueryBuilders.boolQuery();
BaseQueryBuilder fq = QueryBuilders.fieldQuery(fiedname, quertpattern);
fq = new BaseQueryBuilder()
{
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException
{
builder.startObject("multi_match");
builder.field("query", quertpattern);
builder.field("fields",fiedname);
builder.field("type", "phrase");
builder.field("operator", "and");
builder.endObject();
}
};

query.must(fq);


(system) #2