summaryrefslogtreecommitdiffstats
path: root/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp')
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp
index 726afcc959b..104309f50fa 100644
--- a/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp
@@ -3,6 +3,7 @@
#include "indexenvironment.h"
#include <vespa/searchlib/fef/i_ranking_assets_repo.h>
#include <vespa/searchlib/fef/indexproperties.h>
+#include <vespa/vespalib/stllike/hash_set.h>
using namespace search::fef;
@@ -39,6 +40,37 @@ IndexEnvironment::addField(const vespalib::string& name,
return true;
}
+/*
+ * Ensure that array and map fields are known by the index
+ * environment, allowing the matches features to be used with the
+ * sameElement query operator. FieldSearchSpecMap::buildFromConfig()
+ * propagates the name to field id mapping for the added virtual
+ * fields.
+ */
+void
+IndexEnvironment::add_virtual_fields()
+{
+ vespalib::hash_set<vespalib::string> vfields;
+ for (auto& field : _fields) {
+ vespalib::stringref name(field.name());
+ auto pos = name.rfind('.');
+ while (pos != vespalib::string::npos) {
+ name = name.substr(0, pos);
+ if (_fieldNames.contains(name)) {
+ break;
+ }
+ vfields.insert(name);
+ pos = name.rfind('.');
+ }
+ }
+ for (auto& vfield : vfields) {
+ FieldInfo info(FieldType::VIRTUAL, FieldInfo::CollectionType::ARRAY, vfield, _fields.size());
+ info.set_data_type(FieldInfo::DataType::COMBINED);
+ _fields.push_back(info);
+ _fieldNames[vfield] = info.id();
+ }
+}
+
void
IndexEnvironment::fixup_fields()
{