diff --git a/src/filter.cpp b/src/filter.cpp index 95b512ba..757bb4b7 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -639,10 +639,6 @@ Option toFilter(const std::string expression, std::vector filter_values; StringUtils::split_to_values( raw_value.substr(filter_value_index + 1, raw_value.size() - filter_value_index - 2), filter_values); - if (filter_values.empty()) { - return Option(400, "Error with filter field `" + _field.name + - "`: Filter value array cannot be empty."); - } if(_field.stem) { auto stemmer = _field.get_stemmer(); for (std::string& filter_value: filter_values) { diff --git a/test/collection_filtering_test.cpp b/test/collection_filtering_test.cpp index 8e236f4f..63fac08c 100644 --- a/test/collection_filtering_test.cpp +++ b/test/collection_filtering_test.cpp @@ -1593,6 +1593,9 @@ TEST_F(CollectionFilteringTest, NegationOperatorBasics) { results = coll1->search("*", {"artist"}, "artist:![Swift, Jackson]", {}, {}, {0}, 10, 1, FREQUENCY, {true}, 10).get(); ASSERT_EQ(0, results["found"]); + results = coll1->search("*", {"artist"}, "artist:!=[]", {}, {}, {0}, 10, 1, FREQUENCY, {true}, 10).get(); + ASSERT_EQ(4, results["found"]); + // empty value (bad filtering) auto res_op = coll1->search("*", {"artist"}, "artist:!=", {}, {}, {0}, 10, 1, FREQUENCY, {true}, 10); ASSERT_FALSE(res_op.ok()); @@ -1610,10 +1613,6 @@ TEST_F(CollectionFilteringTest, NegationOperatorBasics) { ASSERT_FALSE(res_op.ok()); ASSERT_EQ("Error with filter field `artist`: Filter value cannot be empty.", res_op.error()); - res_op = coll1->search("*", {"artist"}, "artist:!=[]", {}, {}, {0}, 10, 1, FREQUENCY, {true}, 10); - ASSERT_FALSE(res_op.ok()); - ASSERT_EQ("Error with filter field `artist`: Filter value array cannot be empty.", res_op.error()); - collectionManager.drop_collection("coll1"); } @@ -1677,6 +1676,11 @@ TEST_F(CollectionFilteringTest, FilterStringsWithComma) { ASSERT_EQ(1, results["found"].get()); ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get().c_str()); + results = coll1->search("*", {"place"}, "place: []", {}, {}, {0}, 10, 1, + FREQUENCY, {true}, 10).get(); + + ASSERT_EQ(0, results["found"].get()); + collectionManager.drop_collection("coll1"); }