| 73 | }; |
| 74 | |
| 75 | TEST_F(IndexerTest, HashTag) { |
| 76 | redis::Hash db(storage_.get(), ns); |
| 77 | auto cfhandler = storage_->GetCFHandle(ColumnFamilyID::Search); |
| 78 | |
| 79 | { |
| 80 | auto s = indexer.Record(*ctx_, "no_exist", ns); |
| 81 | ASSERT_TRUE(s.Is<Status::NoPrefixMatched>()); |
| 82 | } |
| 83 | |
| 84 | auto key1 = "idxtesthash:k1"; |
| 85 | auto idxname = "hashtest"; |
| 86 | |
| 87 | { |
| 88 | auto s = indexer.Record(*ctx_, key1, ns); |
| 89 | ASSERT_EQ(s.Msg(), Status::ok_msg); |
| 90 | ASSERT_EQ(s->updater->info->name, idxname); |
| 91 | ASSERT_TRUE(s->fields.empty()); |
| 92 | |
| 93 | uint64_t cnt = 0; |
| 94 | db.Set(*ctx_, key1, "x", "food,kitChen,Beauty", &cnt); |
| 95 | ASSERT_EQ(cnt, 1); |
| 96 | |
| 97 | auto s2 = indexer.Update(*ctx_, *s); |
| 98 | ASSERT_TRUE(s2); |
| 99 | |
| 100 | auto key = redis::SearchKey(ns, idxname, "x").ConstructTagFieldData("food", key1); |
| 101 | |
| 102 | std::string val; |
| 103 | auto s3 = storage_->Get(*ctx_, ctx_->DefaultMultiGetOptions(), cfhandler, key, &val); |
| 104 | ASSERT_TRUE(s3.ok()); |
| 105 | ASSERT_EQ(val, ""); |
| 106 | |
| 107 | key = redis::SearchKey(ns, idxname, "x").ConstructTagFieldData("kitchen", key1); |
| 108 | |
| 109 | s3 = storage_->Get(*ctx_, ctx_->DefaultMultiGetOptions(), cfhandler, key, &val); |
| 110 | ASSERT_TRUE(s3.ok()); |
| 111 | ASSERT_EQ(val, ""); |
| 112 | |
| 113 | key = redis::SearchKey(ns, idxname, "x").ConstructTagFieldData("beauty", key1); |
| 114 | |
| 115 | s3 = storage_->Get(*ctx_, ctx_->DefaultMultiGetOptions(), cfhandler, key, &val); |
| 116 | ASSERT_TRUE(s3.ok()); |
| 117 | ASSERT_EQ(val, ""); |
| 118 | } |
| 119 | |
| 120 | { |
| 121 | auto s = indexer.Record(*ctx_, key1, ns); |
| 122 | ASSERT_TRUE(s); |
| 123 | ASSERT_EQ(s->updater->info->name, idxname); |
| 124 | ASSERT_EQ(s->fields.size(), 1); |
| 125 | ASSERT_EQ(s->fields["x"], T("food,kitChen,Beauty")); |
| 126 | |
| 127 | uint64_t cnt = 0; |
| 128 | auto s_set = db.Set(*ctx_, key1, "x", "Clothing,FOOD,sport ", &cnt); |
| 129 | ASSERT_EQ(cnt, 0); |
| 130 | ASSERT_TRUE(s_set.ok()); |
| 131 | |
| 132 | auto s2 = indexer.Update(*ctx_, *s); |
nothing calls this directly
no test coverage detected