Skip to content

Commit

Permalink
Revert "Filter refactoring: Introduce toFilter() and fromXContent() i…
Browse files Browse the repository at this point in the history
…n FilterBuilders and FilterParsers"

This reverts commit 580ef6f given that FilterBuilder and FilterParser are going away with #10985

Conflicts:
	src/main/java/org/elasticsearch/index/query/BaseFilterBuilder.java
	src/main/java/org/elasticsearch/index/query/BaseFilterParser.java
	src/main/java/org/elasticsearch/index/query/BaseFilterParserTemp.java
	src/main/java/org/elasticsearch/index/query/FilterWrappingFilterBuilder.java
  • Loading branch information
javanna committed May 7, 2015
1 parent bcdc371 commit 0dbffbe
Show file tree
Hide file tree
Showing 66 changed files with 43 additions and 369 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
}
builder.endObject();
}

@Override
protected String parserName() {
return AndFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
*
*/
public class AndFilterParser extends BaseFilterParserTemp {
public class AndFilterParser implements FilterParser {

public static final String NAME = "and";

Expand Down
20 changes: 3 additions & 17 deletions src/main/java/org/elasticsearch/index/query/BaseFilterBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.index.query;

import org.apache.lucene.search.Filter;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand All @@ -28,6 +27,9 @@

import java.io.IOException;

/**
*
*/
public abstract class BaseFilterBuilder implements FilterBuilder {

@Override
Expand Down Expand Up @@ -67,20 +69,4 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}

protected abstract void doXContent(XContentBuilder builder, Params params) throws IOException;

/**
* Temporary default implementation for toFilter that parses the filter using its filter parser
*/
//norelease to be removed once all filter builders override toFilter providing their own specific implementation.
@Override
public Filter toFilter(QueryParseContext parseContext) throws IOException {
return parseContext.indexQueryParserService().filterParser(parserName()).parse(parseContext);
}

/**
* Temporary method that allows to retrieve the parser for each filter.
* @return the name of the parser class the default {@link #toFilter(QueryParseContext)} method delegates to
*/
//norelease to be removed once all filter builders override toFilter providing their own specific implementation.
protected abstract String parserName();
}
39 changes: 0 additions & 39 deletions src/main/java/org/elasticsearch/index/query/BaseFilterParser.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,4 @@ private void doXArrayContent(String field, List<FilterBuilder> clauses, XContent
builder.endArray();
}
}

@Override
protected String parserName() {
return BoolFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
*
*/
public class BoolFilterParser extends BaseFilterParserTemp {
public class BoolFilterParser implements FilterParser {

public static final String NAME = "bool";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.copyCurrentStructure(parser);
}
}

@Override
protected String parserName() {
//TODO this class is going to be removed, will disappear once we get #10919 in
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
}
builder.endObject();
}

@Override
protected String parserName() {
return ExistsFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/**
*
*/
public class ExistsFilterParser extends BaseFilterParserTemp {
public class ExistsFilterParser implements FilterParser {

public static final String NAME = "exists";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* The "fquery" filter is the same as the {@link QueryFilterParser} except that it allows also to
* associate a name with the query filter.
*/
public class FQueryFilterParser extends BaseFilterParserTemp {
public class FQueryFilterParser implements FilterParser {

public static final String NAME = "fquery";

Expand Down
14 changes: 4 additions & 10 deletions src/main/java/org/elasticsearch/index/query/FilterBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,18 @@

package org.elasticsearch.index.query;

import org.apache.lucene.search.Filter;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

/**
*
*/
public interface FilterBuilder extends ToXContent {

BytesReference buildAsBytes();

BytesReference buildAsBytes(XContentType contentType);

/**
* Converts this FilterBuilder to a lucene {@link Filter}
* @param parseContext additional information needed to construct the filter
* @return the {@link Filter}
* @throws IOException
*/
Filter toFilter(QueryParseContext parseContext) throws IOException;
}
14 changes: 0 additions & 14 deletions src/main/java/org/elasticsearch/index/query/FilterParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,4 @@ public interface FilterParser {
//norelease can be removed in favour of fromXContent once search requests can be parsed on the coordinating node
@Nullable
Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException;

/**
* Creates a new {@link FilterBuilder} from the filter held by the {@link QueryParseContext}
* in {@link org.elasticsearch.common.xcontent.XContent} format
*
* @param parseContext
* the input parse context. The state on the parser contained in
* this context will be changed as a side effect of this method
* call
* @return the new FilterBuilder
* @throws IOException
* @throws QueryParsingException
*/
FilterBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

builder.endObject();
}

@Override
protected String parserName() {
return GeoBoundingBoxFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/**
*
*/
public class GeoBoundingBoxFilterParser extends BaseFilterParserTemp {
public class GeoBoundingBoxFilterParser implements FilterParser {

public static final String TOP = "top";
public static final String LEFT = "left";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
}
builder.endObject();
}

@Override
protected String parserName() {
return GeoDistanceFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* }
* </pre>
*/
public class GeoDistanceFilterParser extends BaseFilterParserTemp {
public class GeoDistanceFilterParser implements FilterParser {

public static final String NAME = "geo_distance";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
}
builder.endObject();
}

@Override
protected String parserName() {
return GeoDistanceRangeFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* }
* </pre>
*/
public class GeoDistanceRangeFilterParser extends BaseFilterParserTemp {
public class GeoDistanceRangeFilterParser implements FilterParser {

public static final String NAME = "geo_distance_range";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

builder.endObject();
}

@Override
protected String parserName() {
return GeoPolygonFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* }
* </pre>
*/
public class GeoPolygonFilterParser extends BaseFilterParserTemp {
public class GeoPolygonFilterParser implements FilterParser {

public static final String NAME = "geo_polygon";
public static final String POINTS = "points";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,4 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep

builder.endObject();
}

@Override
protected String parserName() {
return GeoShapeFilterParser.NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* }
* </pre>
*/
public class GeoShapeFilterParser extends BaseFilterParserTemp {
public class GeoShapeFilterParser implements FilterParser {

public static final String NAME = "geo_shape";

Expand Down
Loading

0 comments on commit 0dbffbe

Please sign in to comment.