summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@vespa.ai>2024-06-10 17:57:22 +0200
committerGitHub <noreply@github.com>2024-06-10 17:57:22 +0200
commitccfb0e8294b21dd799adf41ca892f69763c1b222 (patch)
tree5cc9a9dfcbda3372b8bb97cab6a1a238029fd3eb
parent717d0019cc8e3ab3dd42b3ec846425cf86c619ee (diff)
parent8b30081be868596dbeeabb01505ee4279243d297 (diff)
Merge pull request #31520 from vespa-engine/havardpe/print-searched-field-and-term
print query term and field name
-rw-r--r--searchlib/src/apps/vespa-query-analyzer/vespa-query-analyzer.cpp50
1 files changed, 36 insertions, 14 deletions
diff --git a/searchlib/src/apps/vespa-query-analyzer/vespa-query-analyzer.cpp b/searchlib/src/apps/vespa-query-analyzer/vespa-query-analyzer.cpp
index 16722a7e135..ea7dd673aa0 100644
--- a/searchlib/src/apps/vespa-query-analyzer/vespa-query-analyzer.cpp
+++ b/searchlib/src/apps/vespa-query-analyzer/vespa-query-analyzer.cpp
@@ -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);
- }
- }
}
}
@@ -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;
@@ -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();
@@ -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;