Skip to content

Commit

Permalink
Merge pull request #31520 from vespa-engine/havardpe/print-searched-f…
Browse files Browse the repository at this point in the history
…ield-and-term

print query term and field name
  • Loading branch information
geirst authored Jun 10, 2024
2 parents 717d001 + 8b30081 commit ccfb0e8
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions searchlib/src/apps/vespa-query-analyzer/vespa-query-analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,12 @@ int rel_diff(double a, double b, double e, double m) {
}

void apply_diff(vespalib::string &str, int diff, char small, char big, int len) {
if (diff < len) {
for (int i = 0; i < diff; ++i) {
for (int i = 0; i < diff && i < len; ++i) {
if (diff + i >= len * 2) {
str.append(big);
} else {
str.append(small);
}
} else {
diff -= len;
for (int i = 0; i < len; ++i) {
if (diff > i) {
str.append(big);
} else {
str.append(small);
}
}
}
}

Expand Down Expand Up @@ -311,6 +304,8 @@ struct Node {
vespalib::string type = "unknown";
uint32_t id = 0;
uint32_t docid_limit = 0;
vespalib::string field_name;
vespalib::string query_term;
bool strict = false;
FlowStats flow_stats = FlowStats(0.0, 0.0, 0.0);
size_t count = 0;
Expand All @@ -328,6 +323,26 @@ struct Node {
type = strip_name(type);
id = obj["id"].asLong();
docid_limit = obj["docid_limit"].asLong();
query_term = obj["query_term"].asString().make_stringref();
if (query_term.size() > 0) {
const Inspector &attr = obj["attribute"];
if (attr.valid()) {
field_name = attr["name"].asString().make_stringref();
if (type == "AttributeFieldBlueprint") {
type = fmt("Attribute{%s,%s}",
attr["type"].asString().make_string().c_str(),
attr["fast_search"].asBool() ? "fs" : "lookup");
}
} else {
field_name = obj["field_name"].asString().make_stringref();
if (type == "DiskTermBlueprint") {
type = "DiskTerm";
}
if (type == "MemoryTermBlueprint") {
type = "MemoryTerm";
}
}
}
strict = obj["strict"].asBool();
flow_stats.estimate = obj["relative_estimate"].asDouble();
flow_stats.cost = obj["cost"].asDouble();
Expand All @@ -344,11 +359,18 @@ struct Node {
}
~Node();
vespalib::string name() const {
vespalib::string res = type;
if (id > 0) {
return fmt("%s[%u]", type.c_str(), id);
} else {
return fmt("%s", type.c_str());
res.append(fmt("[%u]", id));
}
if (query_term.size() > 0) {
if (field_name.size() > 0) {
res.append(fmt(" %s:%s", field_name.c_str(), query_term.c_str()));
} else {
res.append(fmt(" %s", query_term.c_str()));
}
}
return res;
}
double rel_count() const {
return double(count) / docid_limit;
Expand Down

0 comments on commit ccfb0e8

Please sign in to comment.