Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/flight/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ std::string assemble(const std::vector<std::pair<std::string, std::string>>& cla
// ---------------------------------------------------------------------------

QueryTopicBuilder& QueryTopicBuilder::withName(const std::string& name) {
clauses_.emplace_back("locator", opEq(name));
// The server's name/identity filter key is "name". It was "locator" until
// mosaicod #565 renamed it; a stale "locator" key silently matches nothing
// against current servers. (The streaming ticket descriptor still uses
// "resource_locator" — only the query filter key changed.)
clauses_.emplace_back("name", opEq(name));
return *this;
}
QueryTopicBuilder& QueryTopicBuilder::withNameMatch(const std::string& partial) {
clauses_.emplace_back("locator", opMatch(partial));
clauses_.emplace_back("name", opMatch(partial));
return *this;
}
QueryTopicBuilder& QueryTopicBuilder::withOntologyTag(const std::string& tag) {
Expand All @@ -74,11 +78,13 @@ QueryFilter QueryTopicBuilder::build() const {
// ---------------------------------------------------------------------------

QuerySequenceBuilder& QuerySequenceBuilder::withName(const std::string& name) {
clauses_.emplace_back("locator", opEq(name));
// See QueryTopicBuilder::withName — server key renamed "locator" -> "name"
// (mosaicod #565).
clauses_.emplace_back("name", opEq(name));
return *this;
}
QuerySequenceBuilder& QuerySequenceBuilder::withNameMatch(const std::string& partial) {
clauses_.emplace_back("locator", opMatch(partial));
clauses_.emplace_back("name", opMatch(partial));
return *this;
}
QuerySequenceBuilder& QuerySequenceBuilder::withCreatedAfter(int64_t ns) {
Expand Down
6 changes: 3 additions & 3 deletions src/flight/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace mosaico {
// `body_json` is a pre-rendered JSON object (no outer braces quoting issues).
struct QueryFilter {
std::string name;
std::string body_json; // serialized object, e.g. {"locator":{"$eq":"x"}}
std::string body_json; // serialized object, e.g. {"name":{"$eq":"x"}}
};

// Per-topic result entry.
Expand All @@ -41,9 +41,9 @@ struct QueryResponse {
// Fluent builder for QueryTopic filters.
class QueryTopicBuilder {
public:
// Exact match: {"locator": {"$eq": "<name>"}}
// Exact match: {"name": {"$eq": "<name>"}}
QueryTopicBuilder& withName(const std::string& name);
// Partial match: {"locator": {"$match": "<substring>"}}
// Partial match: {"name": {"$match": "<substring>"}}
QueryTopicBuilder& withNameMatch(const std::string& partial);
// Exact tag: {"ontology_tag": {"$eq": "<tag>"}}
QueryTopicBuilder& withOntologyTag(const std::string& tag);
Expand Down