Browse Source

Remove types from percolate query API (#46985)

Type and indexing document type are not used as part of percolate queries
since 7x, so we can remove them from the API entirely.

Part of #41059
Alan Woodward 6 years ago
parent
commit
47bf259f5d

+ 44 - 105
modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.percolator;
 
-import org.apache.logging.log4j.LogManager;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
 import org.apache.lucene.index.BinaryDocValues;
@@ -54,7 +53,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
 import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.logging.DeprecationLogger;
 import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
 import org.elasticsearch.common.xcontent.NamedXContentRegistry;
 import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -92,19 +90,11 @@ import java.util.function.Supplier;
 public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBuilder> {
     public static final String NAME = "percolate";
 
-    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ParseField.class));
-    static final String DOCUMENT_TYPE_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [percolate] queries. " +
-            "The [document_type] should no longer be specified.";
-    static final String TYPE_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [percolate] queries. " +
-            "The [type] of the indexed document should no longer be specified.";
-
     static final ParseField DOCUMENT_FIELD = new ParseField("document");
     static final ParseField DOCUMENTS_FIELD = new ParseField("documents");
     private static final ParseField NAME_FIELD = new ParseField("name");
     private static final ParseField QUERY_FIELD = new ParseField("field");
-    private static final ParseField DOCUMENT_TYPE_FIELD = new ParseField("document_type");
     private static final ParseField INDEXED_DOCUMENT_FIELD_INDEX = new ParseField("index");
-    private static final ParseField INDEXED_DOCUMENT_FIELD_TYPE = new ParseField("type");
     private static final ParseField INDEXED_DOCUMENT_FIELD_ID = new ParseField("id");
     private static final ParseField INDEXED_DOCUMENT_FIELD_ROUTING = new ParseField("routing");
     private static final ParseField INDEXED_DOCUMENT_FIELD_PREFERENCE = new ParseField("preference");
@@ -112,29 +102,16 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
 
     private final String field;
     private String name;
-    @Deprecated
-    private final String documentType;
     private final List<BytesReference> documents;
     private final XContentType documentXContentType;
 
     private final String indexedDocumentIndex;
-    @Deprecated
-    private final String indexedDocumentType;
     private final String indexedDocumentId;
     private final String indexedDocumentRouting;
     private final String indexedDocumentPreference;
     private final Long indexedDocumentVersion;
     private final Supplier<BytesReference> documentSupplier;
 
-    /**
-     * @deprecated use {@link #PercolateQueryBuilder(String, BytesReference, XContentType)} with the document content
-     * type to avoid autodetection.
-     */
-    @Deprecated
-    public PercolateQueryBuilder(String field, String documentType, BytesReference document) {
-        this(field, documentType, Collections.singletonList(document), XContentHelper.xContentType(document));
-    }
-
     /**
      * Creates a percolator query builder instance for percolating a provided document.
      *
@@ -143,7 +120,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
      * @param documentXContentType      The content type of the binary blob containing the document to percolate
      */
     public PercolateQueryBuilder(String field, BytesReference document, XContentType documentXContentType) {
-        this(field, null, Collections.singletonList(document), documentXContentType);
+        this(field, Collections.singletonList(document), documentXContentType);
     }
 
     /**
@@ -154,11 +131,6 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
      * @param documentXContentType      The content type of the binary blob containing the document to percolate
      */
     public PercolateQueryBuilder(String field, List<BytesReference> documents, XContentType documentXContentType) {
-        this(field, null, documents, documentXContentType);
-    }
-
-    @Deprecated
-    public PercolateQueryBuilder(String field, String documentType, List<BytesReference> documents, XContentType documentXContentType) {
         if (field == null) {
             throw new IllegalArgumentException("[field] is a required argument");
         }
@@ -166,11 +138,9 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
             throw new IllegalArgumentException("[document] is a required argument");
         }
         this.field = field;
-        this.documentType = documentType;
         this.documents = documents;
         this.documentXContentType = Objects.requireNonNull(documentXContentType);
         indexedDocumentIndex = null;
-        indexedDocumentType = null;
         indexedDocumentId = null;
         indexedDocumentRouting = null;
         indexedDocumentPreference = null;
@@ -178,43 +148,18 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
         this.documentSupplier = null;
     }
 
-    protected PercolateQueryBuilder(String field, String documentType, Supplier<BytesReference> documentSupplier) {
-        if (field == null) {
-            throw new IllegalArgumentException("[field] is a required argument");
-        }
-        this.field = field;
-        this.documentType = documentType;
-        this.documents = Collections.emptyList();
-        this.documentXContentType = null;
-        this.documentSupplier = documentSupplier;
-        indexedDocumentIndex = null;
-        indexedDocumentType = null;
-        indexedDocumentId = null;
-        indexedDocumentRouting = null;
-        indexedDocumentPreference = null;
-        indexedDocumentVersion = null;
-    }
-
     /**
      * Creates a percolator query builder instance for percolating a document in a remote index.
      *
      * @param field                     The field that contains the percolator query
      * @param indexedDocumentIndex      The index containing the document to percolate
-     * @param indexedDocumentType       The type containing the document to percolate
      * @param indexedDocumentId         The id of the document to percolate
      * @param indexedDocumentRouting    The routing value for the document to percolate
      * @param indexedDocumentPreference The preference to use when fetching the document to percolate
      * @param indexedDocumentVersion    The expected version of the document to percolate
      */
-    public PercolateQueryBuilder(String field, String indexedDocumentIndex, String indexedDocumentType, String indexedDocumentId,
-                                 String indexedDocumentRouting, String indexedDocumentPreference, Long indexedDocumentVersion) {
-        this(field, null, indexedDocumentIndex, indexedDocumentType, indexedDocumentId, indexedDocumentRouting,
-            indexedDocumentPreference, indexedDocumentVersion);
-    }
-
-    @Deprecated
-    public PercolateQueryBuilder(String field, String documentType, String indexedDocumentIndex,
-                                 String indexedDocumentType, String indexedDocumentId, String indexedDocumentRouting,
+    public PercolateQueryBuilder(String field, String indexedDocumentIndex,
+                                 String indexedDocumentId, String indexedDocumentRouting,
                                  String indexedDocumentPreference, Long indexedDocumentVersion) {
         if (field == null) {
             throw new IllegalArgumentException("[field] is a required argument");
@@ -226,9 +171,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
             throw new IllegalArgumentException("[id] is a required argument");
         }
         this.field = field;
-        this.documentType = documentType;
         this.indexedDocumentIndex = indexedDocumentIndex;
-        this.indexedDocumentType = indexedDocumentType;
         this.indexedDocumentId = indexedDocumentId;
         this.indexedDocumentRouting = indexedDocumentRouting;
         this.indexedDocumentPreference = indexedDocumentPreference;
@@ -238,6 +181,21 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
         this.documentSupplier = null;
     }
 
+    protected PercolateQueryBuilder(String field, Supplier<BytesReference> documentSupplier) {
+        if (field == null) {
+            throw new IllegalArgumentException("[field] is a required argument");
+        }
+        this.field = field;
+        this.documents = Collections.emptyList();
+        this.documentXContentType = null;
+        this.documentSupplier = documentSupplier;
+        indexedDocumentIndex = null;
+        indexedDocumentId = null;
+        indexedDocumentRouting = null;
+        indexedDocumentPreference = null;
+        indexedDocumentVersion = null;
+    }
+
     /**
      * Read from a stream.
      */
@@ -245,9 +203,15 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
         super(in);
         field = in.readString();
         name = in.readOptionalString();
-        documentType = in.readOptionalString();
+        if (in.getVersion().before(Version.V_8_0_0)) {
+            String documentType = in.readOptionalString();
+            assert documentType == null;
+        }
         indexedDocumentIndex = in.readOptionalString();
-        indexedDocumentType = in.readOptionalString();
+        if (in.getVersion().before(Version.V_8_0_0)) {
+            String indexedDocumentType = in.readOptionalString();
+            assert indexedDocumentType == null;
+        }
         indexedDocumentId = in.readOptionalString();
         indexedDocumentRouting = in.readOptionalString();
         indexedDocumentPreference = in.readOptionalString();
@@ -281,9 +245,15 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
         }
         out.writeString(field);
         out.writeOptionalString(name);
-        out.writeOptionalString(documentType);
+        if (out.getVersion().before(Version.V_8_0_0)) {
+            // In 7x, typeless percolate queries are represented by null documentType values
+            out.writeOptionalString(null);
+        }
         out.writeOptionalString(indexedDocumentIndex);
-        out.writeOptionalString(indexedDocumentType);
+        if (out.getVersion().before(Version.V_8_0_0)) {
+            // In 7x, typeless percolate queries are represented by null indexedDocumentType values
+            out.writeOptionalString(null);
+        }
         out.writeOptionalString(indexedDocumentId);
         out.writeOptionalString(indexedDocumentRouting);
         out.writeOptionalString(indexedDocumentPreference);
@@ -305,7 +275,6 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
     @Override
     protected void doXContent(XContentBuilder builder, Params params) throws IOException {
         builder.startObject(NAME);
-        builder.field(DOCUMENT_TYPE_FIELD.getPreferredName(), documentType);
         builder.field(QUERY_FIELD.getPreferredName(), field);
         if (name != null) {
             builder.field(NAME_FIELD.getPreferredName(), name);
@@ -321,13 +290,10 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
             }
             builder.endArray();
         }
-        if (indexedDocumentIndex != null || indexedDocumentType != null || indexedDocumentId != null) {
+        if (indexedDocumentIndex != null || indexedDocumentId != null) {
             if (indexedDocumentIndex != null) {
                 builder.field(INDEXED_DOCUMENT_FIELD_INDEX.getPreferredName(), indexedDocumentIndex);
             }
-            if (indexedDocumentType != null) {
-                builder.field(INDEXED_DOCUMENT_FIELD_TYPE.getPreferredName(), indexedDocumentType);
-            }
             if (indexedDocumentId != null) {
                 builder.field(INDEXED_DOCUMENT_FIELD_ID.getPreferredName(), indexedDocumentId);
             }
@@ -350,10 +316,8 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
 
         String field = null;
         String name = null;
-        String documentType = null;
 
         String indexedDocumentIndex = null;
-        String indexedDocumentType = null;
         String indexedDocumentId = null;
         String indexedDocumentRouting = null;
         String indexedDocumentPreference = null;
@@ -415,12 +379,8 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
                     field = parser.text();
                 } else if (NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
                     name = parser.textOrNull();
-                } else if (DOCUMENT_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
-                    documentType = parser.textOrNull();
                 } else if (INDEXED_DOCUMENT_FIELD_INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
                     indexedDocumentIndex = parser.text();
-                } else if (INDEXED_DOCUMENT_FIELD_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
-                    indexedDocumentType = parser.text();
                 } else if (INDEXED_DOCUMENT_FIELD_ID.match(currentFieldName, parser.getDeprecationHandler())) {
                     indexedDocumentId = parser.text();
                 } else if (INDEXED_DOCUMENT_FIELD_ROUTING.match(currentFieldName, parser.getDeprecationHandler())) {
@@ -445,10 +405,10 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
 
         PercolateQueryBuilder queryBuilder;
         if (documents.isEmpty() == false) {
-            queryBuilder = new PercolateQueryBuilder(field, documentType, documents, XContentType.JSON);
+            queryBuilder = new PercolateQueryBuilder(field, documents, XContentType.JSON);
         } else if (indexedDocumentId != null) {
-            queryBuilder = new PercolateQueryBuilder(field, documentType, indexedDocumentIndex, indexedDocumentType,
-                    indexedDocumentId, indexedDocumentRouting, indexedDocumentPreference, indexedDocumentVersion);
+            queryBuilder = new PercolateQueryBuilder(field, indexedDocumentIndex, indexedDocumentId, indexedDocumentRouting,
+                indexedDocumentPreference, indexedDocumentVersion);
         } else {
             throw new IllegalArgumentException("[" + PercolateQueryBuilder.NAME + "] query, nothing to percolate");
         }
@@ -463,10 +423,8 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
     @Override
     protected boolean doEquals(PercolateQueryBuilder other) {
         return Objects.equals(field, other.field)
-                && Objects.equals(documentType, other.documentType)
                 && Objects.equals(documents, other.documents)
                 && Objects.equals(indexedDocumentIndex, other.indexedDocumentIndex)
-                && Objects.equals(indexedDocumentType, other.indexedDocumentType)
                 && Objects.equals(documentSupplier, other.documentSupplier)
                 && Objects.equals(indexedDocumentId, other.indexedDocumentId);
 
@@ -474,7 +432,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
 
     @Override
     protected int doHashCode() {
-        return Objects.hash(field, documentType, documents, indexedDocumentIndex, indexedDocumentType, indexedDocumentId, documentSupplier);
+        return Objects.hash(field, documents, indexedDocumentIndex, indexedDocumentId, documentSupplier);
     }
 
     @Override
@@ -491,7 +449,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
             if (source == null) {
                 return this; // not executed yet
             } else {
-                PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentType,
+                PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field,
                     Collections.singletonList(source), XContentHelper.xContentType(source));
                 if (name != null) {
                     rewritten.setName(name);
@@ -499,13 +457,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
                 return rewritten;
             }
         }
-        GetRequest getRequest;
-        if (indexedDocumentType != null) {
-            deprecationLogger.deprecatedAndMaybeLog("percolate_with_type", TYPE_DEPRECATION_MESSAGE);
-            getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId);
-        } else {
-            getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId);
-        }
+        GetRequest getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId);
         getRequest.preference("_local");
         getRequest.routing(indexedDocumentRouting);
         getRequest.preference(indexedDocumentPreference);
@@ -517,14 +469,12 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
             client.get(getRequest, ActionListener.wrap(getResponse -> {
                 if (getResponse.isExists() == false) {
                     throw new ResourceNotFoundException(
-                        "indexed document [{}{}/{}] couldn't be found", indexedDocumentIndex,
-                        indexedDocumentType == null ? "" : "/" + indexedDocumentType, indexedDocumentId
+                        "indexed document [{}/{}] couldn't be found", indexedDocumentIndex, indexedDocumentId
                     );
                 }
                 if(getResponse.isSourceEmpty()) {
                     throw new IllegalArgumentException(
-                        "indexed document [" + indexedDocumentIndex + (indexedDocumentType == null ? "" : "/" + indexedDocumentType) +
-                        "/" + indexedDocumentId + "] source disabled"
+                        "indexed document [" + indexedDocumentIndex + "/" + indexedDocumentId + "] source disabled"
                     );
                 }
                 documentSupplier.set(getResponse.getSourceAsBytesRef());
@@ -532,7 +482,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
             }, listener::onFailure));
         });
 
-        PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentType, documentSupplier::get);
+        PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentSupplier::get);
         if (name != null) {
             rewritten.setName(name);
         }
@@ -566,13 +516,6 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
         final DocumentMapper docMapper;
         final MapperService mapperService = context.getMapperService();
         String type = mapperService.documentMapper().type();
-        if (documentType != null) {
-            deprecationLogger.deprecatedAndMaybeLog("percolate_with_document_type", DOCUMENT_TYPE_DEPRECATION_MESSAGE);
-            if (documentType.equals(type) == false) {
-                throw new IllegalArgumentException("specified document_type [" + documentType +
-                    "] is not equal to the actual type [" + type + "]");
-            }
-        }
         docMapper = mapperService.documentMapper(type);
         for (BytesReference document : documents) {
             docs.add(docMapper.parse(new SourceToParse(context.index().getName(), type, "_temp_id", document, documentXContentType)));
@@ -622,10 +565,6 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
         return field;
     }
 
-    public String getDocumentType() {
-        return documentType;
-    }
-
     public List<BytesReference> getDocuments() {
         return documents;
     }

+ 8 - 30
modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java

@@ -121,10 +121,10 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
             indexedDocumentRouting = randomAlphaOfLength(4);
             indexedDocumentPreference = randomAlphaOfLength(4);
             indexedDocumentVersion = (long) randomIntBetween(0, Integer.MAX_VALUE);
-            queryBuilder = new PercolateQueryBuilder(queryField, null, indexedDocumentIndex, null, indexedDocumentId,
+            queryBuilder = new PercolateQueryBuilder(queryField, indexedDocumentIndex, indexedDocumentId,
                     indexedDocumentRouting, indexedDocumentPreference, indexedDocumentVersion);
         } else {
-            queryBuilder = new PercolateQueryBuilder(queryField, null, documentSource, XContentType.JSON);
+            queryBuilder = new PercolateQueryBuilder(queryField, documentSource, XContentType.JSON);
         }
         if (randomBoolean()) {
             queryBuilder.setName(randomAlphaOfLength(4));
@@ -166,7 +166,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
     protected void doAssertLuceneQuery(PercolateQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException {
         assertThat(query, Matchers.instanceOf(PercolateQuery.class));
         PercolateQuery percolateQuery = (PercolateQuery) query;
-        assertNull(queryBuilder.getDocumentType());
         assertThat(percolateQuery.getDocuments(), Matchers.equalTo(documentSource));
     }
 
@@ -177,7 +176,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
         assertThat(e.getMessage(), equalTo("query builder must be rewritten first"));
         QueryBuilder rewrite = rewriteAndFetch(pqb, createShardContext());
         PercolateQueryBuilder geoShapeQueryBuilder =
-            new PercolateQueryBuilder(pqb.getField(), pqb.getDocumentType(), documentSource, XContentType.JSON);
+            new PercolateQueryBuilder(pqb.getField(), documentSource, XContentType.JSON);
         assertEquals(geoShapeQueryBuilder, rewrite);
     }
 
@@ -205,21 +204,21 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
         assertThat(e.getMessage(), equalTo("[field] is a required argument"));
 
         e = expectThrows(IllegalArgumentException.class,
-            () -> new PercolateQueryBuilder("_field", "_document_type", null, null));
+            () -> new PercolateQueryBuilder("_field", (List<BytesReference>)null, XContentType.JSON));
         assertThat(e.getMessage(), equalTo("[document] is a required argument"));
 
         e = expectThrows(IllegalArgumentException.class, () -> {
-            new PercolateQueryBuilder(null, null, "_index", "_type", "_id", null, null, null);
+            new PercolateQueryBuilder(null, "_index", "_id", null, null, null);
         });
         assertThat(e.getMessage(), equalTo("[field] is a required argument"));
 
         e = expectThrows(IllegalArgumentException.class, () -> {
-            new PercolateQueryBuilder("_field", "_document_type", null, "_type", "_id", null, null, null);
+            new PercolateQueryBuilder("_field", null, "_id", null, null, null);
         });
         assertThat(e.getMessage(), equalTo("[index] is a required argument"));
 
         e = expectThrows(IllegalArgumentException.class, () -> {
-            new PercolateQueryBuilder("_field", "_document_type", "_index", "_type", null, null, null, null);
+            new PercolateQueryBuilder("_field", "_index", null, null, null, null);
         });
         assertThat(e.getMessage(), equalTo("[id] is a required argument"));
     }
@@ -230,14 +229,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
         queryBuilder.toQuery(queryShardContext);
     }
 
-    public void testFromJsonWithDocumentType() throws IOException {
-        QueryShardContext queryShardContext = createShardContext();
-        QueryBuilder queryBuilder = parseQuery("{\"percolate\" : { \"document\": {}, \"document_type\":\"" + docType  + "\", \"field\":\"" +
-                queryField + "\"}}");
-        queryBuilder.toQuery(queryShardContext);
-        assertWarnings(PercolateQueryBuilder.DOCUMENT_TYPE_DEPRECATION_MESSAGE);
-    }
-
     public void testFromJsonNoType() throws IOException {
         indexedDocumentIndex = randomAlphaOfLength(4);
         indexedDocumentId = randomAlphaOfLength(4);
@@ -250,19 +241,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
         rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext);
     }
 
-    public void testFromJsonWithType() throws IOException {
-        indexedDocumentIndex = randomAlphaOfLength(4);
-        indexedDocumentId = randomAlphaOfLength(4);
-        indexedDocumentVersion = Versions.MATCH_ANY;
-        documentSource = Collections.singletonList(randomSource(new HashSet<>()));
-
-        QueryShardContext queryShardContext = createShardContext();
-        QueryBuilder queryBuilder =  parseQuery("{\"percolate\" : { \"index\": \"" + indexedDocumentIndex +
-                "\", \"type\": \"_doc\", \"id\": \"" + indexedDocumentId + "\", \"field\":\"" + queryField + "\"}}");
-        rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext);
-        assertWarnings(PercolateQueryBuilder.TYPE_DEPRECATION_MESSAGE);
-    }
-
     public void testBothDocumentAndDocumentsSpecified() throws IOException {
         expectThrows(IllegalArgumentException.class,
             () -> parseQuery("{\"percolate\" : { \"document\": {}, \"documents\": [{}, {}], \"field\":\"" + queryField + "\"}}"));
@@ -354,7 +332,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
         Supplier<BytesReference> supplier = () -> new BytesArray("{\"test\": \"test\"}");
         String testName = "name1";
         QueryShardContext shardContext = createShardContext();
-        PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(queryField, null, supplier);
+        PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(queryField, supplier);
         percolateQueryBuilder.setName(testName);
 
         QueryBuilder rewrittenQueryBuilder = percolateQueryBuilder.doRewrite(shardContext);

+ 7 - 7
modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java

@@ -303,14 +303,14 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
 
         logger.info("percolating empty doc");
         SearchResponse response = client().prepareSearch()
-                .setQuery(new PercolateQueryBuilder("query", "test", "type", "1", null, null, null))
+                .setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null))
                 .get();
         assertHitCount(response, 1);
         assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
 
         logger.info("percolating doc with 1 field");
         response = client().prepareSearch()
-                .setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null))
+                .setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null))
                 .addSort("_id", SortOrder.ASC)
                 .get();
         assertHitCount(response, 2);
@@ -319,7 +319,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
 
         logger.info("percolating doc with 2 fields");
         response = client().prepareSearch()
-                .setQuery(new PercolateQueryBuilder("query", "test", "type", "6", null, null, null))
+                .setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null))
                 .addSort("_id", SortOrder.ASC)
                 .get();
         assertHitCount(response, 3);
@@ -343,7 +343,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
         logger.info("percolating empty doc with source disabled");
         IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
             client().prepareSearch()
-                .setQuery(new PercolateQueryBuilder("query", "test", "type", "1", null, null, null))
+                .setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null))
                 .get();
         });
         assertThat(e.getMessage(), containsString("source disabled"));
@@ -806,9 +806,9 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
                 .setQuery(new PercolateQueryBuilder("query",
                     BytesReference.bytes(jsonBuilder().startObject().field("field1", "d").endObject()), XContentType.JSON)))
             .add(client().prepareSearch("test")
-                .setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null)))
+                .setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null)))
             .add(client().prepareSearch("test") // non existing doc, so error element
-                .setQuery(new PercolateQueryBuilder("query", "test", "type", "6", null, null, null)))
+                .setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null)))
             .get();
 
         MultiSearchResponse.Item item = response.getResponses()[0];
@@ -839,7 +839,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
         item = response.getResponses()[5];
         assertThat(item.getResponse(), nullValue());
         assertThat(item.getFailureMessage(), notNullValue());
-        assertThat(item.getFailureMessage(), containsString("[test/type/6] couldn't be found"));
+        assertThat(item.getFailureMessage(), containsString("[test/6] couldn't be found"));
     }
 
 }

+ 0 - 96
modules/percolator/src/test/resources/rest-api-spec/test/11_basic_with_types.yml

@@ -1,96 +0,0 @@
----
-"Test percolator basics via rest":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: queries_index
-        body:
-          mappings:
-            queries_type:
-              properties:
-                query:
-                  type: percolator
-                foo:
-                  type: keyword
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: documents_index
-        body:
-          mappings:
-            documents_type:
-              properties:
-                foo:
-                  type: keyword
-
-  - do:
-      index:
-        index: queries_index
-        type: queries_type
-        id:   test_percolator
-        body:
-          query:
-            match_all: {}
-
-  - do:
-      index:
-        index: documents_index
-        type: documents_type
-        id: some_id
-        body:
-          foo: bar
-
-  - do:
-        indices.refresh: {}
-
-  - do:
-      search:
-        rest_total_hits_as_int: true
-        body:
-          - query:
-              percolate:
-                field: query
-                document:
-                  document_type: queries_type
-                  foo: bar
-  - match:  { hits.total:     1  }
-
-  - do:
-      msearch:
-        rest_total_hits_as_int: true
-        body:
-          - index: queries_index
-          - query:
-              percolate:
-                field: query
-                document_type: queries_type
-                document:
-                  foo: bar
-  - match:  { responses.0.hits.total:     1  }
-
-  - do:
-      search:
-        rest_total_hits_as_int: true
-        body:
-          - query:
-              percolate:
-                field: query
-                index: documents_index
-                type: documents_type
-                id: some_id 
-  - match:  { hits.total:     1  }
-
-  - do:
-      msearch:
-        rest_total_hits_as_int: true
-        body:
-          - index: queries_index
-          - query:
-              percolate:
-                field: query
-                index: documents_index
-                type: documents_type
-                id: some_id
-  - match:  { responses.0.hits.total:     1  }