Deprecate span_near's collect_payloads
This commit is contained in:
parent
b29c416b7c
commit
ae0bf1b32f
|
@ -43,17 +43,12 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
|
|||
/** Default for flag controlling whether matches are required to be in-order */
|
||||
public static boolean DEFAULT_IN_ORDER = true;
|
||||
|
||||
/** Default for flag controlling whether payloads are collected */
|
||||
public static boolean DEFAULT_COLLECT_PAYLOADS = true;
|
||||
|
||||
private final List<SpanQueryBuilder> clauses = new ArrayList<>();
|
||||
|
||||
private final int slop;
|
||||
|
||||
private boolean inOrder = DEFAULT_IN_ORDER;
|
||||
|
||||
private boolean collectPayloads = DEFAULT_COLLECT_PAYLOADS;
|
||||
|
||||
static final SpanNearQueryBuilder PROTOTYPE = new SpanNearQueryBuilder(SpanTermQueryBuilder.PROTOTYPE, 0);
|
||||
|
||||
/**
|
||||
|
@ -107,21 +102,6 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
|
|||
return this.inOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param collectPayloads flag controlling whether payloads are collected
|
||||
*/
|
||||
public SpanNearQueryBuilder collectPayloads(boolean collectPayloads) {
|
||||
this.collectPayloads = collectPayloads;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SpanNearQueryBuilder#collectPayloads(boolean)
|
||||
*/
|
||||
public boolean collectPayloads() {
|
||||
return this.collectPayloads;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(NAME);
|
||||
|
@ -132,7 +112,6 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
|
|||
builder.endArray();
|
||||
builder.field(SpanNearQueryParser.SLOP_FIELD.getPreferredName(), slop);
|
||||
builder.field(SpanNearQueryParser.IN_ORDER_FIELD.getPreferredName(), inOrder);
|
||||
builder.field(SpanNearQueryParser.COLLECT_PAYLOADS_FIELD.getPreferredName(), collectPayloads);
|
||||
printBoostAndQueryName(builder);
|
||||
builder.endObject();
|
||||
}
|
||||
|
@ -145,7 +124,7 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
|
|||
assert query instanceof SpanQuery;
|
||||
spanQueries[i] = (SpanQuery) query;
|
||||
}
|
||||
return new SpanNearQuery(spanQueries, slop, inOrder, collectPayloads);
|
||||
return new SpanNearQuery(spanQueries, slop, inOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,7 +134,6 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
|
|||
for (int i = 1; i < clauses.size(); i++) {
|
||||
queryBuilder.clauses.add((SpanQueryBuilder)clauses.get(i));
|
||||
}
|
||||
queryBuilder.collectPayloads = in.readBoolean();
|
||||
queryBuilder.inOrder = in.readBoolean();
|
||||
return queryBuilder;
|
||||
|
||||
|
@ -165,20 +143,18 @@ public class SpanNearQueryBuilder extends AbstractQueryBuilder<SpanNearQueryBuil
|
|||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
writeQueries(out, clauses);
|
||||
out.writeVInt(slop);
|
||||
out.writeBoolean(collectPayloads);
|
||||
out.writeBoolean(inOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int doHashCode() {
|
||||
return Objects.hash(clauses, slop, collectPayloads, inOrder);
|
||||
return Objects.hash(clauses, slop, inOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doEquals(SpanNearQueryBuilder other) {
|
||||
return Objects.equals(clauses, other.clauses) &&
|
||||
Objects.equals(slop, other.slop) &&
|
||||
Objects.equals(collectPayloads, other.collectPayloads) &&
|
||||
Objects.equals(inOrder, other.inOrder);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ public class SpanNearQueryParser implements QueryParser<SpanNearQueryBuilder> {
|
|||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
Integer slop = null;
|
||||
boolean inOrder = SpanNearQueryBuilder.DEFAULT_IN_ORDER;
|
||||
boolean collectPayloads = SpanNearQueryBuilder.DEFAULT_COLLECT_PAYLOADS;
|
||||
String queryName = null;
|
||||
|
||||
List<SpanQueryBuilder> clauses = new ArrayList<>();
|
||||
|
@ -76,7 +75,7 @@ public class SpanNearQueryParser implements QueryParser<SpanNearQueryBuilder> {
|
|||
if (parseContext.parseFieldMatcher().match(currentFieldName, IN_ORDER_FIELD)) {
|
||||
inOrder = parser.booleanValue();
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, COLLECT_PAYLOADS_FIELD)) {
|
||||
collectPayloads = parser.booleanValue();
|
||||
// Deprecated in 3.0.0
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, SLOP_FIELD)) {
|
||||
slop = parser.intValue();
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.BOOST_FIELD)) {
|
||||
|
@ -104,7 +103,6 @@ public class SpanNearQueryParser implements QueryParser<SpanNearQueryBuilder> {
|
|||
queryBuilder.clause(clauses.get(i));
|
||||
}
|
||||
queryBuilder.inOrder(inOrder);
|
||||
queryBuilder.collectPayloads(collectPayloads);
|
||||
queryBuilder.boost(boost);
|
||||
queryBuilder.queryName(queryName);
|
||||
return queryBuilder;
|
||||
|
|
|
@ -331,8 +331,7 @@ public class QueryDSLDocumentationTests extends ESTestCase {
|
|||
spanNearQuery(spanTermQuery("field","value1"), 12)
|
||||
.clause(spanTermQuery("field","value2"))
|
||||
.clause(spanTermQuery("field","value3"))
|
||||
.inOrder(false)
|
||||
.collectPayloads(false);
|
||||
.inOrder(false);
|
||||
}
|
||||
|
||||
public void testSpanNot() {
|
||||
|
|
|
@ -77,7 +77,6 @@ public class SpanContainingQueryBuilderTests extends AbstractQueryTestCase<SpanC
|
|||
" } ],\n" +
|
||||
" \"slop\" : 5,\n" +
|
||||
" \"in_order\" : true,\n" +
|
||||
" \"collect_payloads\" : true,\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.query;
|
|||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.spans.SpanNearQuery;
|
||||
import org.apache.lucene.search.spans.SpanQuery;
|
||||
import org.elasticsearch.Version;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
@ -38,7 +39,6 @@ public class SpanNearQueryBuilderTests extends AbstractQueryTestCase<SpanNearQue
|
|||
queryBuilder.clause(spanTermQueries[i]);
|
||||
}
|
||||
queryBuilder.inOrder(randomBoolean());
|
||||
queryBuilder.collectPayloads(randomBoolean());
|
||||
return queryBuilder;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ public class SpanNearQueryBuilderTests extends AbstractQueryTestCase<SpanNearQue
|
|||
" } ],\n" +
|
||||
" \"slop\" : 12,\n" +
|
||||
" \"in_order\" : false,\n" +
|
||||
" \"collect_payloads\" : false,\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
@ -111,6 +110,42 @@ public class SpanNearQueryBuilderTests extends AbstractQueryTestCase<SpanNearQue
|
|||
assertEquals(json, 3, parsed.clauses().size());
|
||||
assertEquals(json, 12, parsed.slop());
|
||||
assertEquals(json, false, parsed.inOrder());
|
||||
assertEquals(json, false, parsed.collectPayloads());
|
||||
}
|
||||
|
||||
public void testCollectPayloadsDeprecated() throws Exception {
|
||||
assertEquals("We can remove support for ignoring collect_payloads in 4.0", 3, Version.CURRENT.major);
|
||||
String json =
|
||||
"{\n" +
|
||||
" \"span_near\" : {\n" +
|
||||
" \"clauses\" : [ {\n" +
|
||||
" \"span_term\" : {\n" +
|
||||
" \"field\" : {\n" +
|
||||
" \"value\" : \"value1\",\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }, {\n" +
|
||||
" \"span_term\" : {\n" +
|
||||
" \"field\" : {\n" +
|
||||
" \"value\" : \"value2\",\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }, {\n" +
|
||||
" \"span_term\" : {\n" +
|
||||
" \"field\" : {\n" +
|
||||
" \"value\" : \"value3\",\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" } ],\n" +
|
||||
" \"slop\" : 12,\n" +
|
||||
" \"in_order\" : false,\n" +
|
||||
" \"collect_payloads\" : false,\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
parseQuery(json); // Just don't throw an error and we're fine
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,6 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
|
|||
" } ],\n" +
|
||||
" \"slop\" : 0,\n" +
|
||||
" \"in_order\" : true,\n" +
|
||||
" \"collect_payloads\" : true,\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
|
|
|
@ -77,7 +77,6 @@ public class SpanWithinQueryBuilderTests extends AbstractQueryTestCase<SpanWithi
|
|||
" } ],\n" +
|
||||
" \"slop\" : 5,\n" +
|
||||
" \"in_order\" : true,\n" +
|
||||
" \"collect_payloads\" : true,\n" +
|
||||
" \"boost\" : 1.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
|
|
|
@ -150,6 +150,10 @@ Removed support for the deprecated top level `filter` in the search api, replace
|
|||
|
||||
Removed support for the undocumented `query_binary` and `filter_binary` sections of a search request.
|
||||
|
||||
==== `span_near`'s' `collect_payloads` deprecated
|
||||
|
||||
Payloads are now loaded when needed.
|
||||
|
||||
[[breaking_30_parent_child_changes]]
|
||||
=== Parent/Child changes
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ matches are required to be in-order. The span near query maps to Lucene
|
|||
{ "span_term" : { "field" : "value3" } }
|
||||
],
|
||||
"slop" : 12,
|
||||
"in_order" : false,
|
||||
"collect_payloads" : false
|
||||
"in_order" : false
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue