aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-10-30 15:26:12 +0100
committerTor Egge <Tor.Egge@online.no>2023-10-30 15:26:12 +0100
commit1b2aa2aa93b600cfd26e3f1920c9c63ab7ddf609 (patch)
tree8ab9450c4881624e0519a31708023c07562b135d /searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
parent621520610face5ad70122a4ddecb61e2222798d8 (diff)
Add attribute tokens dfw.
Diffstat (limited to 'searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp')
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
index 2f7d9acdb65..28a2c34ca87 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attribute_combiner_dfw.h"
+#include "attribute_tokens_dfw.h"
#include "copy_dfw.h"
#include "docsum_field_writer_commands.h"
#include "docsum_field_writer_factory.h"
@@ -16,8 +17,10 @@
#include "tokens_dfw.h"
#include <vespa/searchlib/common/matching_elements_fields.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <vespa/vespalib/util/issue.h>
using vespalib::IllegalArgumentException;
+using vespalib::Issue;
namespace search::docsummary {
@@ -91,6 +94,21 @@ DocsumFieldWriterFactory::create_docsum_field_writer(const vespalib::string& fie
} else {
throw_missing_source(command);
}
+ } else if (command == command::attribute_tokens) {
+ if (!source.empty()) {
+ if (has_attribute_manager()) {
+ auto ctx = getEnvironment().getAttributeManager()->createContext();
+ const auto* attr = ctx->getAttribute(source);
+ if (attr == nullptr) {
+ Issue::report("No valid attribute vector found: field='%s', command='%s', source='%s'",
+ field_name.c_str(), command.c_str(), source.c_str());
+ } else {
+ fieldWriter = std::make_unique<AttributeTokensDFW>(source);
+ }
+ }
+ } else {
+ throw_missing_source(command);
+ }
} else if (command == command::abs_distance) {
if (has_attribute_manager()) {
fieldWriter = AbsDistanceDFW::create(source.c_str(), getEnvironment().getAttributeManager());