aboutsummaryrefslogtreecommitdiffstats
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
parent229b6ec3ecf88a5920bc478cb8c902af3a48b5be (diff)
Put commands for docsum field writers at a common place.
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp75
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp33
-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
-rw-r--r--streamingvisitors/src/vespa/vsm/vsm/docsum_field_writer_factory.cpp25
7 files changed, 138 insertions, 74 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp
index f2433b2adf6..d7904881e4d 100644
--- a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp
@@ -7,6 +7,7 @@
#include <vespa/searchcore/proton/common/i_document_type_inspector.h>
#include <vespa/searchcore/proton/common/indexschema_inspector.h>
#include <vespa/searchcore/proton/test/attribute_utils.h>
+#include <vespa/searchsummary/docsummary/docsum_field_writer_commands.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/test/insertion_operators.h>
@@ -14,13 +15,15 @@
#include <vespa/log/log.h>
LOG_SETUP("attibute_aspect_delayer_test");
+using search::attribute::Config;
using vespa::config::search::AttributesConfig;
using vespa::config::search::AttributesConfigBuilder;
using vespa::config::search::IndexschemaConfig;
using vespa::config::search::IndexschemaConfigBuilder;
using vespa::config::search::SummaryConfig;
using vespa::config::search::SummaryConfigBuilder;
-using search::attribute::Config;
+
+using namespace search::docsummary;
namespace vespa::config::search::internal {
@@ -192,15 +195,17 @@ TEST_F(DelayerTest, require_that_empty_config_is_ok)
TEST_F(DelayerTest, require_that_simple_attribute_config_is_ok)
{
- setup(attrCfg({make_int32_sv_cfg()}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a", "integer", "attribute", "a")}));
+ setup(attrCfg({make_int32_sv_cfg()}), attrCfg({make_int32_sv_cfg()}),
+ sCfg({make_summary_field("a", "integer", command::attribute, "a")}));
assertAttributeConfig({make_int32_sv_cfg()});
- assertSummaryConfig({make_summary_field("a", "integer", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "integer", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_if_field_type_is_unchanged)
{
addFields({"a"});
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a", "integer", "attribute", "a")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}),
+ sCfg({make_summary_field("a", "integer", command::attribute, "a")}));
assertAttributeConfig({});
assertSummaryConfig({make_summary_field("a", "integer")});
}
@@ -208,24 +213,27 @@ TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_if_field_typ
TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_if_field_type_is_unchanged_geopos_override)
{
addFields({"a"});
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a", "integer", "geopos", "a")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}),
+ sCfg({make_summary_field("a", "integer", command::geo_position, "a")}));
assertAttributeConfig({});
- assertSummaryConfig({make_summary_field("a", "integer", "geopos", "a")});
+ assertSummaryConfig({make_summary_field("a", "integer", command::geo_position, "a")});
}
TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_if_field_type_is_unchanged_mapped_summary)
{
addFields({"a"});
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a_mapped", "integer", "attribute", "a")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}),
+ sCfg({make_summary_field("a_mapped", "integer", command::attribute, "a")}));
assertAttributeConfig({});
- assertSummaryConfig({make_summary_field("a_mapped", "integer", "copy", "a")});
+ assertSummaryConfig({make_summary_field("a_mapped", "integer", command::copy, "a")});
}
TEST_F(DelayerTest, require_that_adding_attribute_is_not_delayed_if_field_type_changed)
{
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a", "integer", "attribute", "a")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg()}),
+ sCfg({make_summary_field("a", "integer", command::attribute, "a")}));
assertAttributeConfig({make_int32_sv_cfg()});
- assertSummaryConfig({make_summary_field("a", "integer", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "integer", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_removing_attribute_aspect_is_delayed_if_field_type_is_unchanged)
@@ -233,7 +241,7 @@ TEST_F(DelayerTest, require_that_removing_attribute_aspect_is_delayed_if_field_t
addFields({"a"});
setup(attrCfg({make_int32_sv_cfg()}), attrCfg({}), sCfg({make_summary_field("a", "integer")}));
assertAttributeConfig({make_int32_sv_cfg()});
- assertSummaryConfig({make_summary_field("a", "integer", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "integer", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_summary_map_override_is_removed_when_summary_aspect_is_removed_even_if_removing_attribute_aspect_is_delayed)
@@ -272,7 +280,8 @@ TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_for_tensor_f
{
addFields({"a"});
setup(attrCfg({}),
- attrCfg({make_tensor_cfg("tensor(x[10])")}), sCfg({make_summary_field("a", "tensor", "attribute", "a")}));
+ attrCfg({make_tensor_cfg("tensor(x[10])")}),
+ sCfg({make_summary_field("a", "tensor", command::attribute, "a")}));
assertAttributeConfig({});
assertSummaryConfig({make_summary_field("a", "tensor")});
}
@@ -283,7 +292,7 @@ TEST_F(DelayerTest, require_that_removing_attribute_aspect_is_delayed_for_tensor
setup(attrCfg({make_tensor_cfg("tensor(x[10])")}),
attrCfg({}), sCfg({make_summary_field("a", "tensor")}));
assertAttributeConfig({make_tensor_cfg("tensor(x[10])")});
- assertSummaryConfig({make_summary_field("a", "tensor", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "tensor", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_removing_attribute_aspect_is_not_delayed_for_predicate)
@@ -305,56 +314,63 @@ TEST_F(DelayerTest, require_that_removing_attribute_aspect_is_not_delayed_for_re
TEST_F(DelayerTest, require_that_fast_access_flag_change_is_delayed_false_true_edge)
{
addFields({"a"});
- setup(attrCfg({make_int32_sv_cfg()}), attrCfg({make_fa(make_int32_sv_cfg())}), sCfg({make_summary_field("a", "integer", "attribute", "a")}));
+ setup(attrCfg({make_int32_sv_cfg()}), attrCfg({make_fa(make_int32_sv_cfg())}),
+ sCfg({make_summary_field("a", "integer", command::attribute, "a")}));
assertAttributeConfig({make_int32_sv_cfg()});
- assertSummaryConfig({make_summary_field("a", "integer", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "integer", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_fast_access_flag_change_is_delayed_true_false_edge)
{
addFields({"a"});
- setup(attrCfg({make_fa(make_int32_sv_cfg())}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a", "integer", "attribute", "a")}));
+ setup(attrCfg({make_fa(make_int32_sv_cfg())}), attrCfg({make_int32_sv_cfg()}),
+ sCfg({make_summary_field("a", "integer", command::attribute, "a")}));
assertAttributeConfig({make_fa(make_int32_sv_cfg())});
- assertSummaryConfig({make_summary_field("a", "integer", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "integer", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_fast_access_flag_change_is_delayed_false_true_edge_on_tensor_attribute)
{
addFields({"a"});
- setup(attrCfg({make_tensor_cfg("tensor(x[10])")}), attrCfg({make_fa(make_tensor_cfg("tensor(x[10])"))}), sCfg({make_summary_field("a", "tensor", "attribute", "a")}));
+ setup(attrCfg({make_tensor_cfg("tensor(x[10])")}), attrCfg({make_fa(make_tensor_cfg("tensor(x[10])"))}),
+ sCfg({make_summary_field("a", "tensor", command::attribute, "a")}));
assertAttributeConfig({make_tensor_cfg("tensor(x[10])")});
- assertSummaryConfig({make_summary_field("a", "tensor", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "tensor", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_fast_access_flag_change_is_delayed_true_false_edge_on_tensor_attribute)
{
addFields({"a"});
setup(attrCfg({make_fa(make_tensor_cfg("tensor(x[10])"))}),
- attrCfg({make_tensor_cfg("tensor(x[10])")}), sCfg({make_summary_field("a", "tensor", "attribute", "a")}));
+ attrCfg({make_tensor_cfg("tensor(x[10])")}),
+ sCfg({make_summary_field("a", "tensor", command::attribute, "a")}));
assertAttributeConfig({make_fa(make_tensor_cfg("tensor(x[10])"))});
- assertSummaryConfig({make_summary_field("a", "tensor", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "tensor", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_fast_access_flag_change_is_not_delayed_true_false_edge_on_string_attribute_indexed_field)
{
addFields({"a"});
addOldIndexField("a");
- setup(attrCfg({make_fa(make_string_sv_cfg())}), attrCfg({make_string_sv_cfg()}), sCfg({make_summary_field("a", "string", "attribute", "a")}));
+ setup(attrCfg({make_fa(make_string_sv_cfg())}), attrCfg({make_string_sv_cfg()}),
+ sCfg({make_summary_field("a", "string", command::attribute, "a")}));
assertAttributeConfig({make_string_sv_cfg()});
- assertSummaryConfig({make_summary_field("a", "string", "attribute", "a")});
+ assertSummaryConfig({make_summary_field("a", "string", command::attribute, "a")});
}
TEST_F(DelayerTest, require_that_adding_attribute_aspect_to_struct_field_is_not_delayed_if_field_type_is_changed)
{
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg("array.a")}), sCfg({make_summary_field("array", "jsonstring", "attributecombiner", "array")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg("array.a")}),
+ sCfg({make_summary_field("array", "jsonstring", command::attribute_combiner, "array")}));
assertAttributeConfig({make_int32_sv_cfg("array.a")});
- assertSummaryConfig({make_summary_field("array", "jsonstring", "attributecombiner", "array")});
+ assertSummaryConfig({make_summary_field("array", "jsonstring", command::attribute_combiner, "array")});
}
TEST_F(DelayerTest, require_that_adding_attribute_aspect_to_struct_field_is_delayed_if_field_type_is_unchanged)
{
addFields({"array.a"});
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg("array.a")}), sCfg({make_summary_field("array", "jsonstring", "attributecombiner", "array")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg("array.a")}),
+ sCfg({make_summary_field("array", "jsonstring", command::attribute_combiner, "array")}));
assertAttributeConfig({});
assertSummaryConfig({make_summary_field("array", "jsonstring")});
}
@@ -370,9 +386,12 @@ TEST_F(DelayerTest, require_that_removing_attribute_aspect_from_struct_field_is_
TEST_F(DelayerTest, require_that_adding_attribute_aspect_to_struct_field_is_delayed_if_field_type_is_unchanged_with_filtering_docsum)
{
addFields({"array.a"});
- setup(attrCfg({}), attrCfg({make_int32_sv_cfg("array.a")}), sCfg({make_summary_field("array", "jsonstring", "attributecombiner", "array"), make_summary_field("array_filtered", "jsonstring", "matchedattributeelementsfilter", "array")}));
+ setup(attrCfg({}), attrCfg({make_int32_sv_cfg("array.a")}),
+ sCfg({make_summary_field("array", "jsonstring", command::attribute_combiner, "array"),
+ make_summary_field("array_filtered", "jsonstring", command::matched_attribute_elements_filter, "array")}));
assertAttributeConfig({});
- assertSummaryConfig({make_summary_field("array", "jsonstring"), make_summary_field("array_filtered", "jsonstring", "matchedelementsfilter", "array")});
+ assertSummaryConfig({make_summary_field("array", "jsonstring"),
+ make_summary_field("array_filtered", "jsonstring", command::matched_elements_filter, "array")});
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp
index e25bc4c71d5..1b13e80563a 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp
@@ -4,31 +4,28 @@
#include <vespa/config-attributes.h>
#include <vespa/config-summary.h>
#include <vespa/searchcommon/attribute/attribute_utils.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchcore/proton/common/config_hash.hpp>
#include <vespa/searchcore/proton/common/i_document_type_inspector.h>
#include <vespa/searchcore/proton/common/i_indexschema_inspector.h>
#include <vespa/searchlib/attribute/configconverter.h>
-#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/searchsummary/docsummary/docsum_field_writer_commands.h>
#include <vespa/vespalib/stllike/hash_set.hpp>
-using search::attribute::isUpdateableInMemoryOnly;
using search::attribute::BasicType;
using search::attribute::ConfigConverter;
+using search::attribute::isUpdateableInMemoryOnly;
using vespa::config::search::AttributesConfig;
using vespa::config::search::AttributesConfigBuilder;
using vespa::config::search::SummaryConfig;
using vespa::config::search::SummaryConfigBuilder;
+using namespace search::docsummary;
+
namespace proton {
namespace {
-vespalib::string attribute_combiner_dfw_string("attributecombiner");
-vespalib::string matched_attribute_elements_filter_dfw_string("matchedattributeelementsfilter");
-vespalib::string matched_elements_filter_dfw_string("matchedelementsfilter");
-vespalib::string copy_dfw_string("copy");
-vespalib::string attribute_dfw_string("attribute");
-
using AttributesConfigHash = ConfigHash<AttributesConfig::Attribute>;
bool willTriggerReprocessOnAttributeAspectRemoval(const search::attribute::Config &cfg,
@@ -53,7 +50,7 @@ void
remove_docsum_field_rewriter(SummaryConfig::Classes::Fields& summary_field)
{
if (source_field(summary_field) != summary_field.name) {
- summary_field.command = copy_dfw_string;
+ summary_field.command = command::copy;
} else {
summary_field.command = "";
summary_field.source = "";
@@ -225,31 +222,31 @@ AttributeAspectConfigRewriter::build_summary_config(const SummaryConfig& new_sum
summary_config_builder = new_summary_config;
for (auto &summary_class : summary_config_builder.classes) {
for (auto &summary_field : summary_class.fields) {
- if (summary_field.command == attribute_dfw_string) {
+ if (summary_field.command == command::attribute) {
if (is_delayed_add_attribute_aspect(source_field(summary_field))) {
remove_docsum_field_rewriter(summary_field);
}
- } else if (summary_field.command == attribute_combiner_dfw_string) {
+ } else if (summary_field.command == command::attribute_combiner) {
if (is_delayed_add_attribute_aspect_struct(source_field(summary_field))) {
remove_docsum_field_rewriter(summary_field);
}
- } else if (summary_field.command == matched_attribute_elements_filter_dfw_string) {
+ } else if (summary_field.command == command::matched_attribute_elements_filter) {
if (is_delayed_add_attribute_aspect_struct(source_field(summary_field)) ||
is_delayed_add_attribute_aspect(source_field(summary_field))) {
- summary_field.command = matched_elements_filter_dfw_string;
+ summary_field.command = command::matched_elements_filter;
}
- } else if (summary_field.command == matched_elements_filter_dfw_string) {
+ } else if (summary_field.command == command::matched_elements_filter) {
if (is_delayed_remove_attribute_aspect(source_field(summary_field))) {
- summary_field.command = matched_attribute_elements_filter_dfw_string;
+ summary_field.command = command::matched_attribute_elements_filter;
}
} else if (summary_field.command == "") {
if (is_delayed_remove_attribute_aspect(summary_field.name)) {
- summary_field.command = attribute_dfw_string;
+ summary_field.command = command::attribute;
summary_field.source = summary_field.name;
}
- } else if (summary_field.command == copy_dfw_string) {
+ } else if (summary_field.command == command::copy) {
if (is_delayed_remove_attribute_aspect(source_field(summary_field))) {
- summary_field.command = attribute_dfw_string;
+ summary_field.command = command::attribute;
summary_field.source = source_field(summary_field);
}
}
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 + "'.");
diff --git a/streamingvisitors/src/vespa/vsm/vsm/docsum_field_writer_factory.cpp b/streamingvisitors/src/vespa/vsm/vsm/docsum_field_writer_factory.cpp
index d5ecb158edb..eaef0846536 100644
--- a/streamingvisitors/src/vespa/vsm/vsm/docsum_field_writer_factory.cpp
+++ b/streamingvisitors/src/vespa/vsm/vsm/docsum_field_writer_factory.cpp
@@ -1,18 +1,19 @@
// 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 <vespa/searchlib/common/matching_elements_fields.h>
#include <vespa/searchsummary/docsummary/copy_dfw.h>
#include <vespa/searchsummary/docsummary/docsum_field_writer.h>
+#include <vespa/searchsummary/docsummary/docsum_field_writer_commands.h>
#include <vespa/searchsummary/docsummary/empty_dfw.h>
#include <vespa/searchsummary/docsummary/matched_elements_filter_dfw.h>
-#include <vespa/searchlib/common/matching_elements_fields.h>
#include <vespa/vsm/config/config-vsmfields.h>
using search::MatchingElementsFields;
using search::docsummary::CopyDFW;
+using search::docsummary::DocsumFieldWriter;
using search::docsummary::EmptyDFW;
using search::docsummary::IDocsumEnvironment;
-using search::docsummary::DocsumFieldWriter;
using search::docsummary::MatchedElementsFilterDFW;
using vespa::config::search::vsm::VsmfieldsConfig;
@@ -49,23 +50,19 @@ DocsumFieldWriterFactory::create_docsum_field_writer(const vespalib::string& fie
const vespalib::string& source)
{
std::unique_ptr<DocsumFieldWriter> fieldWriter;
- if ((command == "staticrank") ||
- (command == "ranklog") ||
- (command == "label") ||
- (command == "project") ||
- (command == "positions") ||
- (command == "absdist") ||
- (command == "subproject"))
+ using namespace search::docsummary;
+ if ((command == command::positions) ||
+ (command == command::abs_distance))
{
fieldWriter = std::make_unique<EmptyDFW>();
- } else if ((command == "attribute") ||
- (command == "attributecombiner")) {
+ } else if ((command == command::attribute) ||
+ (command == command::attribute_combiner)) {
if (!source.empty() && source != field_name) {
fieldWriter = std::make_unique<CopyDFW>(source);
}
- } else if (command == "geopos") {
- } else if ((command == "matchedattributeelementsfilter") ||
- (command == "matchedelementsfilter")) {
+ } else if (command == command::geo_position) {
+ } else if ((command == command::matched_attribute_elements_filter) ||
+ (command == command::matched_elements_filter)) {
vespalib::string source_field = source.empty() ? field_name : source;
populate_fields(*_matching_elems_fields, _vsm_fields_config, source_field);
fieldWriter = MatchedElementsFilterDFW::create(source_field, _matching_elems_fields);