Skip to content

Commit

Permalink
[Remove] Type from Percolate query API (#2490)
Browse files Browse the repository at this point in the history
* [Remove] Type from Percolator query API

Signed-off-by: Suraj Singh <[email protected]>

* Address review comment

Signed-off-by: Suraj Singh <[email protected]>
  • Loading branch information
dreamer-89 authored Mar 18, 2022
1 parent b9f0440 commit 9f83dea
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ public void testPercolatorQueryExistingDocument() throws Exception {

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);
Expand All @@ -413,7 +413,7 @@ public void testPercolatorQueryExistingDocument() throws Exception {

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);
Expand All @@ -438,7 +438,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception
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)).get(); }
() -> { client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get(); }
);
assertThat(e.getMessage(), containsString("source disabled"));
}
Expand Down Expand Up @@ -1193,10 +1193,10 @@ public void testPercolatorQueryViaMultiSearch() throws Exception {
)
)
)
.add(client().prepareSearch("test").setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null)))
.add(client().prepareSearch("test").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();

Expand Down Expand Up @@ -1228,7 +1228,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception {
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"));
}

public void testDisallowExpensiveQueries() throws IOException {
Expand Down
Loading

0 comments on commit 9f83dea

Please sign in to comment.