summaryrefslogtreecommitdiffstats
path: root/searchsummary
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2022-09-19 09:51:10 +0000
committerGeir Storli <geirst@yahooinc.com>2022-09-19 09:51:10 +0000
commit2737d0850c5890d87c2842034925029ab88868d4 (patch)
tree502bec587c9e46c1008a5ebb41b9c546463da86b /searchsummary
parent229b6ec3ecf88a5920bc478cb8c902af3a48b5be (diff)
Put commands for docsum field writers at a common place.
Diffstat (limited to 'searchsummary')
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt1
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.cpp22
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.h27
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp29
4 files changed, 65 insertions, 14 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt
index be435b49348..37ee0697149 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt
+++ b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt
@@ -9,6 +9,7 @@ vespa_add_library(searchsummary_docsummary OBJECT
check_undefined_value_visitor.cpp
copy_dfw.cpp
docsum_field_writer.cpp
+ docsum_field_writer_commands.cpp
docsum_field_writer_factory.cpp
docsum_store_document.cpp
docsumstate.cpp
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.cpp
new file mode 100644
index 00000000000..b04963a5907
--- /dev/null
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.cpp
@@ -0,0 +1,22 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "docsum_field_writer_commands.h"
+
+namespace search::docsummary::command {
+
+const vespalib::string abs_distance("absdist");
+const vespalib::string attribute("attribute");
+const vespalib::string attribute_combiner("attributecombiner");
+const vespalib::string copy("copy");
+const vespalib::string documentid("documentid");
+const vespalib::string dynamic_teaser("dynamicteaser");
+const vespalib::string empty("empty");
+const vespalib::string geo_position("geopos");
+const vespalib::string matched_attribute_elements_filter("matchedattributeelementsfilter");
+const vespalib::string matched_elements_filter("matchedelementsfilter");
+const vespalib::string positions("positions");
+const vespalib::string rank_features("rankfeatures");
+const vespalib::string summary_features("summaryfeatures");
+
+}
+
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.h b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.h
new file mode 100644
index 00000000000..8ca508a6b60
--- /dev/null
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_commands.h
@@ -0,0 +1,27 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/vespalib/stllike/string.h>
+
+namespace search::docsummary::command {
+
+/**
+ * This contains all commands that map to specific docsum field writer(s) when setting up a summary result class.
+ */
+
+extern const vespalib::string abs_distance;
+extern const vespalib::string attribute;
+extern const vespalib::string attribute_combiner;
+extern const vespalib::string copy;
+extern const vespalib::string documentid;
+extern const vespalib::string dynamic_teaser;
+extern const vespalib::string empty;
+extern const vespalib::string geo_position;
+extern const vespalib::string matched_attribute_elements_filter;
+extern const vespalib::string matched_elements_filter;
+extern const vespalib::string positions;
+extern const vespalib::string rank_features;
+extern const vespalib::string summary_features;
+
+}
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 fb00b759574..dc215d9c2ba 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsum_field_writer_factory.cpp
@@ -1,8 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "docsum_field_writer_factory.h"
#include "attribute_combiner_dfw.h"
#include "copy_dfw.h"
+#include "docsum_field_writer_commands.h"
+#include "docsum_field_writer_factory.h"
#include "document_id_dfw.h"
#include "empty_dfw.h"
#include "geoposdfw.h"
@@ -59,7 +60,7 @@ DocsumFieldWriterFactory::create_docsum_field_writer(const vespalib::string& fie
const vespalib::string& source)
{
std::unique_ptr<DocsumFieldWriter> fieldWriter;
- if (command == "dynamicteaser") {
+ if (command == command::dynamic_teaser) {
if ( ! source.empty() ) {
auto fw = std::make_unique<DynamicTeaserDFW>(getEnvironment().getJuniper());
auto fw_ptr = fw.get();
@@ -70,46 +71,46 @@ DocsumFieldWriterFactory::create_docsum_field_writer(const vespalib::string& fie
} else {
throw_missing_source(command);
}
- } else if (command == "summaryfeatures") {
+ } else if (command == command::summary_features) {
fieldWriter = std::make_unique<SummaryFeaturesDFW>();
- } else if (command == "rankfeatures") {
+ } else if (command == command::rank_features) {
fieldWriter = std::make_unique<RankFeaturesDFW>();
- } else if (command == "empty") {
+ } else if (command == command::empty) {
fieldWriter = std::make_unique<EmptyDFW>();
- } else if (command == "copy") {
+ } else if (command == command::copy) {
if ( ! source.empty() ) {
fieldWriter = std::make_unique<CopyDFW>(source);
} else {
throw_missing_source(command);
}
- } else if (command == "absdist") {
+ } else if (command == command::abs_distance) {
if (has_attribute_manager()) {
fieldWriter = AbsDistanceDFW::create(source.c_str(), getEnvironment().getAttributeManager());
throw_if_nullptr(fieldWriter, command);
}
- } else if (command == "positions") {
+ } else if (command == command::positions) {
if (has_attribute_manager()) {
fieldWriter = PositionsDFW::create(source.c_str(), getEnvironment().getAttributeManager(), _use_v8_geo_positions);
throw_if_nullptr(fieldWriter, command);
}
- } else if (command == "geopos") {
+ } else if (command == command::geo_position) {
if (has_attribute_manager()) {
fieldWriter = GeoPositionDFW::create(source.c_str(), getEnvironment().getAttributeManager(), _use_v8_geo_positions);
throw_if_nullptr(fieldWriter, command);
}
- } else if (command == "attribute") {
+ } else if (command == command::attribute) {
if (has_attribute_manager()) {
fieldWriter = AttributeDFWFactory::create(*getEnvironment().getAttributeManager(), source);
// Missing attribute vector is allowed, so throw_if_nullptr() is NOT used.
}
- } else if (command == "attributecombiner") {
+ } else if (command == command::attribute_combiner) {
if (has_attribute_manager()) {
auto attr_ctx = getEnvironment().getAttributeManager()->createContext();
const vespalib::string& source_field = source.empty() ? field_name : source;
fieldWriter = AttributeCombinerDFW::create(source_field, *attr_ctx, false, std::shared_ptr<MatchingElementsFields>());
throw_if_nullptr(fieldWriter, command);
}
- } else if (command == "matchedattributeelementsfilter") {
+ } else if (command == command::matched_attribute_elements_filter) {
const vespalib::string& source_field = source.empty() ? field_name : source;
if (has_attribute_manager()) {
auto attr_ctx = getEnvironment().getAttributeManager()->createContext();
@@ -120,14 +121,14 @@ DocsumFieldWriterFactory::create_docsum_field_writer(const vespalib::string& fie
}
throw_if_nullptr(fieldWriter, command);
}
- } else if (command == "matchedelementsfilter") {
+ } else if (command == command::matched_elements_filter) {
const vespalib::string& source_field = source.empty() ? field_name : source;
if (has_attribute_manager()) {
auto attr_ctx = getEnvironment().getAttributeManager()->createContext();
fieldWriter = MatchedElementsFilterDFW::create(source_field,*attr_ctx, _matching_elems_fields);
throw_if_nullptr(fieldWriter, command);
}
- } else if (command == "documentid") {
+ } else if (command == command::documentid) {
fieldWriter = std::make_unique<DocumentIdDFW>();
} else {
throw IllegalArgumentException("Unknown command '" + command + "'.");