diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-07-14 09:07:47 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-07-15 15:39:23 +0000 |
commit | c5fc3ffbbd620f50992ac978fe0dab46a0d19f4f (patch) | |
tree | 98ddca016842b5274cdbe7e8ef039ea3fd27d974 | |
parent | e4f9b819485bcdbd4a0f103268a65004b58650e0 (diff) |
separate finding and processing of ProtonLocationTerm
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/query.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index 42d663c169d..b5d6b6e96e5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -19,6 +19,8 @@ LOG_SETUP(".proton.matching.query"); using document::PositionDataType; using search::SimpleQueryStackDumpIterator; +using search::common::GeoLocation; +using search::common::GeoLocationParser; using search::common::GeoLocationSpec; using search::fef::IIndexEnvironment; using search::fef::ITermData; @@ -57,15 +59,13 @@ inject(Node::UP query, Node::UP to_inject) { return query; } -std::vector<const ProtonLocationTerm *> -fix_location_terms(Node *tree) { - std::vector<const ProtonLocationTerm *> retval; +std::vector<ProtonLocationTerm *> +find_location_terms(Node *tree) { + std::vector<ProtonLocationTerm *> retval; std::vector<Node *> nodes; nodes.push_back(tree); for (size_t i = 0; i < nodes.size(); ++i) { if (auto loc = dynamic_cast<ProtonLocationTerm *>(nodes[i])) { - const string old_view = loc->getView(); - loc->setView(PositionDataType::getZCurveFieldName(old_view)); retval.push_back(loc); } if (auto parent = dynamic_cast<const search::query::Intermediate *>(nodes[i])) { @@ -82,7 +82,7 @@ GeoLocationSpec parseQueryLocationString(string str) { if (str.empty()) { return empty; } - search::common::GeoLocationParser parser; + GeoLocationParser parser; if (parser.parseOldFormatWithField(str)) { auto attr_name = PositionDataType::getZCurveFieldName(parser.getFieldName()); return GeoLocationSpec{attr_name, parser.getGeoLocation()}; @@ -92,6 +92,14 @@ GeoLocationSpec parseQueryLocationString(string str) { return empty; } +GeoLocationSpec process_query_term(ProtonLocationTerm &pterm) { + auto old_view = pterm.getView(); + auto new_view = PositionDataType::getZCurveFieldName(old_view); + pterm.setView(new_view); + const GeoLocation &loc = pterm.getTerm(); + return GeoLocationSpec{new_view, loc}; +} + void exchangeLocationNodes(const string &location_str, Node::UP &query_tree, std::vector<search::fef::Location> &fef_locations) @@ -100,13 +108,11 @@ void exchangeLocationNodes(const string &location_str, auto parsed = parseQueryLocationString(location_str); if (parsed.location.valid()) { - locationSpecs.emplace_back(parsed); + locationSpecs.push_back(parsed); } - for (const ProtonLocationTerm * pterm : fix_location_terms(query_tree.get())) { - std::string view = pterm->getView(); - search::common::GeoLocation loc = pterm->getTerm(); - if (loc.valid()) { - search::common::GeoLocationSpec spec{view, loc}; + for (ProtonLocationTerm * pterm : find_location_terms(query_tree.get())) { + auto spec = process_query_term(*pterm); + if (spec.location.valid()) { locationSpecs.push_back(spec); } } |