mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix: test was added
This commit is contained in:
parent
01e72683b6
commit
4000cef7c4
3 changed files with 32 additions and 3 deletions
|
@ -279,12 +279,14 @@ struct BasicSearch {
|
|||
template <typename C>
|
||||
IndexResult CollectSuffixMatches(BaseStringIndex<C>* index, std::string_view suffix) {
|
||||
// TODO: Implement full text search for suffix
|
||||
error_ = "Not implemented";
|
||||
return IndexResult{};
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
IndexResult CollectInfixMatches(BaseStringIndex<C>* index, std::string_view infix) {
|
||||
// TODO: Implement full text search for infix
|
||||
error_ = "Not implemented";
|
||||
return IndexResult{};
|
||||
}
|
||||
|
||||
|
@ -368,11 +370,13 @@ struct BasicSearch {
|
|||
|
||||
IndexResult Search(const AstSuffixNode& node, string_view active_field) {
|
||||
// TODO: Implement full text search for suffix
|
||||
error_ = "Not implemented";
|
||||
return IndexResult{};
|
||||
}
|
||||
|
||||
IndexResult Search(const AstInfixNode& node, string_view active_field) {
|
||||
// TODO: Implement full text search for infix
|
||||
error_ = "Not implemented";
|
||||
return IndexResult{};
|
||||
}
|
||||
|
||||
|
|
|
@ -237,9 +237,8 @@ TEST_F(SearchParserTest, Parse) {
|
|||
EXPECT_EQ(1, Parse(" @foo:@bar "));
|
||||
EXPECT_EQ(1, Parse(" @foo: "));
|
||||
|
||||
// We don't support suffix/any other position for now
|
||||
EXPECT_EQ(1, Parse("*pre"));
|
||||
EXPECT_EQ(1, Parse("*pre*"));
|
||||
EXPECT_EQ(0, Parse("*suffix"));
|
||||
EXPECT_EQ(0, Parse("*infix"));
|
||||
|
||||
EXPECT_EQ(1, Parse("pre***"));
|
||||
}
|
||||
|
|
|
@ -872,6 +872,32 @@ TEST_F(SearchTest, InvalidVectorParameter) {
|
|||
ASSERT_FALSE(algo.Init("*=>[KNN 2 @v $b]", &query_params));
|
||||
}
|
||||
|
||||
TEST_F(SearchTest, NotImplementedSearchTypes) {
|
||||
auto schema = MakeSimpleSchema({{"title", SchemaField::TEXT}});
|
||||
FieldIndices indices{schema, kEmptyOptions, PMR_NS::get_default_resource(), nullptr};
|
||||
|
||||
SearchAlgorithm algo{};
|
||||
QueryParams params;
|
||||
|
||||
// Add a document for testing
|
||||
MockedDocument doc{Map{{"title", "text for search"}}};
|
||||
indices.Add(0, doc);
|
||||
|
||||
// Test suffix search (words ending with "search")
|
||||
algo.Init("*search", ¶ms);
|
||||
auto suffix_result = algo.Search(&indices);
|
||||
EXPECT_TRUE(suffix_result.ids.empty()) << "Suffix search should return empty result";
|
||||
EXPECT_THAT(suffix_result.error, testing::HasSubstr("Not implemented"))
|
||||
<< "Suffix search should return a not implemented error";
|
||||
|
||||
// Test infix search (words containing "for")
|
||||
algo.Init("*for*", ¶ms);
|
||||
auto infix_result = algo.Search(&indices);
|
||||
EXPECT_TRUE(infix_result.ids.empty()) << "Infix search should return empty result";
|
||||
EXPECT_THAT(infix_result.error, testing::HasSubstr("Not implemented"))
|
||||
<< "Infix search should return a not implemented error";
|
||||
}
|
||||
|
||||
} // namespace search
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue