summaryrefslogtreecommitdiffstats
path: root/streamingvisitors
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-02-19 21:24:25 +0100
committerGitHub <noreply@github.com>2024-02-19 21:24:25 +0100
commit91525f0e94bc150ef9e9879699c158ff93ddb628 (patch)
treee7c141380834a210337d96b75361a0c5eae3bf3b /streamingvisitors
parent8f72e63785af529ea5877e7a7bbcc683cb9a92da (diff)
parent7059a097c51a313ff9a7ef7e16894ce7832e0edc (diff)
Merge pull request #30316 from vespa-engine/balder/use-highlight-termsv8.307.19
Balder/use highlight terms
Diffstat (limited to 'streamingvisitors')
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp33
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.h2
2 files changed, 23 insertions, 12 deletions
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
index 1875664f6c4..e2eb3535223 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
@@ -51,6 +51,7 @@ using vsm::DocsumFilter;
using vsm::FieldPath;
using vsm::StorageDocument;
using vsm::StringFieldIdTMap;
+using vespalib::string;
namespace {
@@ -186,6 +187,7 @@ SearchVisitor::SummaryGenerator::SummaryGenerator(const search::IAttributeManage
_dump_features(),
_location(),
_stack_dump(),
+ _highlight_terms(),
_attr_manager(attr_manager),
_query_normalization(query_normalization)
{
@@ -218,6 +220,7 @@ SearchVisitor::SummaryGenerator::get_streaming_docsums_state(vespalib::stringref
if (_stack_dump.has_value()) {
ds._args.setStackDump(_stack_dump.value().size(), _stack_dump.value().data());
}
+ ds._args.highlightTerms(_highlight_terms);
_docsumWriter->initState(_attr_manager, ds, state->get_resolve_class_info());
auto insres = _docsum_states.insert(std::make_pair(summary_class, std::move(state)));
return *insres.first->second;
@@ -429,21 +432,27 @@ SearchVisitor::init(const Parameters & params)
if (!prop.decode(src, len)) {
LOG(warning, "Could not decode rank properties");
} else {
- LOG(debug, "Properties[%u]: name '%s', size '%u'", i, prop.getName(), prop.size());
- if (strcmp(prop.getName(), "rank") == 0) { // pick up rank properties
+ LOG(debug, "Properties[%u]: name '%s', size '%u'", i, prop.name().c_str(), prop.size());
+ if (prop.name() == "rank") { // pick up rank properties
for (uint32_t j = 0; j < prop.size(); ++j) {
- vespalib::string k{prop.getKey(j), prop.getKeyLen(j)};
- vespalib::string v{prop.getValue(j), prop.getValueLen(j)};
- LOG(debug, "Properties[%u][%u]: key '%s' -> value '%s'", i, j, k.c_str(), v.c_str());
- _rankController.getQueryProperties().add(k, v);
+ LOG(debug, "Properties[%u][%u]: key '%s' -> value '%s'",
+ i, j, string(prop.key(j)).c_str(), string(prop.value(j)).c_str());
+ _rankController.getQueryProperties().add(prop.key(j), prop.value(j));
}
- }
- if (strcmp(prop.getName(), "feature") == 0) { // pick up feature overrides
+ } else if (prop.name() == "feature") { // pick up feature overrides
+ for (uint32_t j = 0; j < prop.size(); ++j) {
+ LOG(debug, "Feature override[%u][%u]: key '%s' -> value '%s'",
+ i, j, string(prop.key(j)).c_str(), string(prop.value(j)).c_str());
+ _rankController.getFeatureOverrides().add(prop.key(j), prop.value(j));
+ }
+ } else if (prop.name() == "highlightterms") {
for (uint32_t j = 0; j < prop.size(); ++j) {
- vespalib::string k{prop.getKey(j), prop.getKeyLen(j)};
- vespalib::string v{prop.getValue(j), prop.getValueLen(j)};
- LOG(debug, "Feature override[%u][%u]: key '%s' -> value '%s'", i, j, k.c_str(), v.c_str());
- _rankController.getFeatureOverrides().add(k, v);
+ LOG(debug, "Hightligthterms[%u][%u]: key '%s' -> value '%s'",
+ i, j, string(prop.key(j)).c_str(), string(prop.value(j)).c_str());
+ vespalib::stringref index = prop.key(j);
+ vespalib::stringref term = prop.value(j);
+ vespalib::string norm_term = QueryNormalization::optional_fold(term, search::TermType::WORD, normalizing_mode(index));
+ _summaryGenerator.highlightTerms().add(index, norm_term);
}
}
}
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h
index 567cb1b1f2f..7d73a159f6f 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h
+++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h
@@ -423,6 +423,7 @@ private:
void set_location(const vespalib::string& location) { _location = location; }
void set_stack_dump(std::vector<char> stack_dump) { _stack_dump = std::move(stack_dump); }
void add_summary_field(vespalib::stringref field) { _summaryFields.emplace_back(field); }
+ search::fef::Properties & highlightTerms() { return _highlight_terms;}
private:
StreamingDocsumsState& get_streaming_docsums_state(vespalib::stringref summary_class);
vsm::GetDocsumsStateCallback _callback;
@@ -434,6 +435,7 @@ private:
std::optional<bool> _dump_features;
std::optional<vespalib::string> _location;
std::optional<std::vector<char>> _stack_dump;
+ search::fef::Properties _highlight_terms;
const search::IAttributeManager& _attr_manager;
const search::QueryNormalization & _query_normalization;
};