Skip to content

Commit

Permalink
Revert adding FQueryFilterBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
cbuescher committed May 22, 2015
1 parent 78191b5 commit f5a4e74
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 70 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public FQueryFilterParser() {

@Override
public String[] names() {
return new String[]{FQueryFilterBuilder.NAME};
return new String[]{QueryFilterBuilder.FQUERY_NAME};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,48 @@
* query as a filter directly.
*/
@Deprecated
public class QueryFilterBuilder extends QueryBuilder<QueryFilterBuilder> {
public class QueryFilterBuilder extends QueryBuilder {

public static final String NAME = "query";

private final QueryBuilder<?> queryBuilder;
// this query builder creates query parsed by FQueryFilterParser in case queryName is set
public static final String FQUERY_NAME = "fquery";

private final QueryBuilder queryBuilder;

private String queryName;

/**
* A filter that simply wraps a query.
*
* @param queryBuilder The query to wrap as a filter
*/
public QueryFilterBuilder(QueryBuilder<?> queryBuilder) {
public QueryFilterBuilder(QueryBuilder queryBuilder) {
this.queryBuilder = queryBuilder;
}

/**
* Sets the query name for the filter that can be used when searching for matched_filters per hit.
*/
public QueryFilterBuilder queryName(String queryName) {
this.queryName = queryName;
return this;
}

@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
if (queryName == null) {
builder.field(NAME);
queryBuilder.toXContent(builder, params);
} else {
builder.startObject(FQUERY_NAME);
builder.field("query");
queryBuilder.toXContent(builder, params);
if (queryName != null) {
builder.field("_name", queryName);
}
builder.endObject();
}
}

@Override
Expand Down

0 comments on commit f5a4e74

Please sign in to comment.