|
@@ -111,6 +111,30 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
|
|
|
assertThat(extendedCommonTermsQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo(queryBuilder.lowFreqMinimumShouldMatch()));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void testUnknownField() throws IOException {
|
|
|
+ super.testUnknownField();
|
|
|
+ assertDeprecationWarning();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void testUnknownObjectException() throws IOException {
|
|
|
+ super.testUnknownObjectException();
|
|
|
+ assertDeprecationWarning();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void testFromXContent() throws IOException {
|
|
|
+ super.testFromXContent();
|
|
|
+ assertDeprecationWarning();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void testValidOutput() throws IOException {
|
|
|
+ super.testValidOutput();
|
|
|
+ assertDeprecationWarning();
|
|
|
+ }
|
|
|
+
|
|
|
public void testIllegalArguments() {
|
|
|
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new CommonTermsQueryBuilder(null, "text"));
|
|
|
assertEquals("field name is null or empty", e.getMessage());
|
|
@@ -146,6 +170,8 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
|
|
|
assertEquals(query, Operator.OR, queryBuilder.lowFreqOperator());
|
|
|
assertEquals(query, Operator.AND, queryBuilder.highFreqOperator());
|
|
|
assertEquals(query, "nelly the elephant not as a cartoon", queryBuilder.value());
|
|
|
+
|
|
|
+ assertDeprecationWarning();
|
|
|
}
|
|
|
|
|
|
public void testCommonTermsQuery1() throws IOException {
|
|
@@ -155,6 +181,8 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
|
|
|
ExtendedCommonTermsQuery ectQuery = (ExtendedCommonTermsQuery) parsedQuery;
|
|
|
assertThat(ectQuery.getHighFreqMinimumNumberShouldMatchSpec(), nullValue());
|
|
|
assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("2"));
|
|
|
+
|
|
|
+ assertDeprecationWarning();
|
|
|
}
|
|
|
|
|
|
public void testCommonTermsQuery2() throws IOException {
|
|
@@ -164,6 +192,8 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
|
|
|
ExtendedCommonTermsQuery ectQuery = (ExtendedCommonTermsQuery) parsedQuery;
|
|
|
assertThat(ectQuery.getHighFreqMinimumNumberShouldMatchSpec(), equalTo("50%"));
|
|
|
assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("5<20%"));
|
|
|
+
|
|
|
+ assertDeprecationWarning();
|
|
|
}
|
|
|
|
|
|
public void testCommonTermsQuery3() throws IOException {
|
|
@@ -173,12 +203,16 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
|
|
|
ExtendedCommonTermsQuery ectQuery = (ExtendedCommonTermsQuery) parsedQuery;
|
|
|
assertThat(ectQuery.getHighFreqMinimumNumberShouldMatchSpec(), nullValue());
|
|
|
assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("2"));
|
|
|
+
|
|
|
+ assertDeprecationWarning();
|
|
|
}
|
|
|
|
|
|
// see #11730
|
|
|
public void testCommonTermsQuery4() throws IOException {
|
|
|
Query parsedQuery = parseQuery(commonTermsQuery("field", "text")).toQuery(createShardContext());
|
|
|
assertThat(parsedQuery, instanceOf(ExtendedCommonTermsQuery.class));
|
|
|
+
|
|
|
+ assertDeprecationWarning();
|
|
|
}
|
|
|
|
|
|
public void testParseFailsWithMultipleFields() throws IOException {
|
|
@@ -204,5 +238,11 @@ public class CommonTermsQueryBuilderTests extends AbstractQueryTestCase<CommonTe
|
|
|
"}";
|
|
|
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
|
|
|
assertEquals("[common] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
|
|
|
+
|
|
|
+ assertDeprecationWarning();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void assertDeprecationWarning() {
|
|
|
+ assertWarnings("Deprecated field [common] used, replaced by [" + CommonTermsQueryBuilder.COMMON_TERMS_QUERY_DEPRECATION_MSG + "]");
|
|
|
}
|
|
|
}
|