Skip to content

Commit

Permalink
Adjust issue report for unsupported search.
Browse files Browse the repository at this point in the history
  • Loading branch information
toregge committed Dec 3, 2024
1 parent 2f11f53 commit 212ae30
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,10 @@ convertPostingBaseToSlime(const IPostingListAttributeBase &postingBase, Cursor &
convertMemoryUsageToSlime(memory_usage.bitvectors, cursor.setObject("bitvectors"));
}

std::string
type_to_string(const Config& cfg)
{
if (cfg.basicType().type() == BasicType::TENSOR) {
return cfg.tensorType().to_spec();
}
if (cfg.collectionType().type() == CollectionType::SINGLE) {
return cfg.basicType().asString();
}
return std::string(cfg.collectionType().asString()) +
"<" + std::string(cfg.basicType().asString()) + ">";
}

void
convert_config_to_slime(const Config& cfg, bool full, Cursor& object)
{
object.setString("type", type_to_string(cfg));
object.setString("type", cfg.type_to_string());
object.setBool("fast_search", cfg.fastSearch());
object.setBool("filter", cfg.getIsFilter());
object.setBool("paged", cfg.paged());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ TEST_F(RawAttributeTest, search_is_not_implemented)
EXPECT_NE(nullptr, dynamic_cast<const EmptySearchContext*>(ctx.get()));
}
std::vector<std::string> exp;
exp.emplace_back("Search is not implemented for attribute 'raw' of type 'search::attribute::SingleRawAttribute'.");
exp.emplace_back("Search is not supported for attribute 'raw' of type 'raw' ('search::attribute::SingleRawAttribute').");
EXPECT_EQ(exp, handler.list);
}

Expand Down
13 changes: 13 additions & 0 deletions searchlib/src/vespa/searchcommon/attribute/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,17 @@ Config::set_hnsw_index_params(const HnswIndexParams& params) {
return *this;
}

std::string
Config::type_to_string() const
{
if (basicType().type() == BasicType::TENSOR) {
return tensorType().to_spec();
}
if (collectionType().type() == CollectionType::SINGLE) {
return basicType().asString();
}
return std::string(collectionType().asString()) +
"<" + std::string(basicType().asString()) + ">";
}

}
1 change: 1 addition & 0 deletions searchlib/src/vespa/searchcommon/attribute/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Config {

uint64_t getMaxUnCommittedMemory() const noexcept { return _maxUnCommittedMemory; }
Config & setMaxUnCommittedMemory(uint64_t value) { _maxUnCommittedMemory = value; return *this; }
std::string type_to_string() const;

private:
BasicType _basicType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ NotImplementedAttribute::addDoc(DocId &) {

std::unique_ptr<SearchContext>
NotImplementedAttribute::getSearch(QueryTermSimpleUP, const attribute::SearchContextParams &) const {
Issue::report("Search is not implemented for attribute '%s' of type '%s'.",
getName().c_str(), getClassName(*this).c_str());
Issue::report("Search is not supported for attribute '%s' of type '%s' ('%s').",
getName().c_str(), getConfig().type_to_string().c_str(), getClassName(*this).c_str());
return std::make_unique<EmptySearchContext>(*this);
}

Expand Down

0 comments on commit 212ae30

Please sign in to comment.