From 839a91edae106d82235ed627c335cdf03be45c30 Mon Sep 17 00:00:00 2001 From: Christopher Peck <27231838+itschrispeck@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:04:17 -0800 Subject: [PATCH] bugfix: re-add support for `not text_match` (#12372) --- .../filter/TextMatchFilterOperator.java | 3 +-- .../pinot/queries/TextSearchQueriesTest.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/TextMatchFilterOperator.java b/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/TextMatchFilterOperator.java index 5c791eb3e62..8a668f593dd 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/TextMatchFilterOperator.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/TextMatchFilterOperator.java @@ -43,8 +43,7 @@ public class TextMatchFilterOperator extends BaseFilterOperator { private final TextMatchPredicate _predicate; public TextMatchFilterOperator(TextIndexReader textIndexReader, TextMatchPredicate predicate, int numDocs) { - // This filter operator does not support AND/OR/NOT operations. - super(0, false); + super(numDocs, false); _textIndexReader = textIndexReader; _predicate = predicate; _numDocs = numDocs; diff --git a/pinot-core/src/test/java/org/apache/pinot/queries/TextSearchQueriesTest.java b/pinot-core/src/test/java/org/apache/pinot/queries/TextSearchQueriesTest.java index ea164c0e6a4..df1b8a790fb 100644 --- a/pinot-core/src/test/java/org/apache/pinot/queries/TextSearchQueriesTest.java +++ b/pinot-core/src/test/java/org/apache/pinot/queries/TextSearchQueriesTest.java @@ -1330,6 +1330,24 @@ public void testTextSearchWithAdditionalFilter() testTextSearchAggregationQueryHelper(query, expected.size()); } + /** + * Test NotFilterOperator with index based doc id iterator (text_match) + * @throws Exception + */ + @Test + public void testTextSearchWithInverse() + throws Exception { + + // all skills except the first 28 in createTestData contain 'software engineering' or ('software' and 'engineering') + List expected = new ArrayList<>(); + for (int i = 0; i < 28; i++) { + expected.add(new Object[]{1000 + i}); + } + + String query = "SELECT INT_COL FROM MyTable WHERE NOT TEXT_MATCH(SKILLS_TEXT_COL, 'software') LIMIT 50000"; + testTextSearchSelectQueryHelper(query, 28, false, expected); + } + /** * Test the reference counting mechanism of {@link SearcherManager} * used by {@link RealtimeLuceneTextIndex}