From 8b30081be868596dbeeabb01505ee4279243d297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersen?= Date: Mon, 10 Jun 2024 14:00:52 +0000 Subject: [PATCH] print query term and field name also print type and fs/lookup for attributes --- .../vespa-query-analyzer.cpp | 50 +++++++++++++------ 1 file 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 16722a7e135c..ea7dd673aa09 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;