summaryrefslogtreecommitdiffstats
path: root/vsm
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-02-04 00:16:30 +0100
committerHenning Baldersheim <balder@oath.com>2018-02-04 00:16:30 +0100
commitaba01adff0736e99747ffc87d47c1ede7b1a8a32 (patch)
tree47de9dcb3e3bda5a69473116fed2733a60832743 /vsm
parent20773f05443d5518fb2ca211b909a953cc91a23b (diff)
Make fieldset resolution recursive.
Diffstat (limited to 'vsm')
-rw-r--r--vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp b/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp
index d2a92897c95..80a072df6af 100644
--- a/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp
+++ b/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp
@@ -21,6 +21,8 @@ using search::ConstQueryTermList;
namespace vsm {
+namespace {
+
void setMatchType(FieldSearcherContainer & searcher, vespalib::stringref arg1) {
if (arg1 == "prefix") {
searcher->setMatchType(FieldSearcher::PREFIX);
@@ -35,6 +37,8 @@ void setMatchType(FieldSearcherContainer & searcher, vespalib::stringref arg1) {
}
}
+}
+
FieldSearchSpec::FieldSearchSpec() :
_id(0),
_name(),
@@ -205,6 +209,36 @@ void FieldSearchSpecMap::buildFromConfig(const std::vector<vespalib::string> & o
}
}
+namespace {
+
+FieldIdTList
+buildFieldSet(const VsmfieldsConfig::Documenttype::Index & ci, const FieldSearchSpecMapT & specMap,
+ const VsmfieldsConfig::Documenttype::IndexVector & indexes)
+{
+ LOG(spam, "Index %s with %zd fields", ci.name.c_str(), ci.field.size());
+ FieldIdTList ifm;
+ for (const VsmfieldsConfig::Documenttype::Index::Field & cf : ci.field) {
+ LOG(spam, "Parsing field %s", cf.name.c_str());
+ auto foundIndex = std::find_if(indexes.begin(), indexes.end(),
+ [&cf](const auto & v) { return v.name == cf.name;});
+ if (foundIndex != indexes.end()) {
+ FieldIdTList sub = buildFieldSet(*foundIndex, specMap, indexes);
+ ifm.insert(ifm.end(), sub.begin(), sub.end());
+ } else {
+ auto foundField = std::find_if(specMap.begin(), specMap.end(),
+ [&cf](const auto & v) { return v.second.name() == cf.name;} );
+ if (foundField != specMap.end()) {
+ ifm.push_back(foundField->second.id());
+ } else {
+ LOG(warning, "Field %s not defined. Ignoring....", cf.name.c_str());
+ }
+ }
+ }
+ return ifm;
+}
+
+}
+
bool FieldSearchSpecMap::buildFromConfig(const VsmfieldsHandle & conf)
{
bool retval(true);
@@ -223,19 +257,7 @@ bool FieldSearchSpecMap::buildFromConfig(const VsmfieldsHandle & conf)
IndexFieldMapT indexMapp;
LOG(spam, "Parsing document type %s with %zd indexes", di.name.c_str(), di.index.size());
for(const VsmfieldsConfig::Documenttype::Index & ci : di.index) {
- LOG(spam, "Index %s with %zd fields", ci.name.c_str(), ci.field.size());
- FieldIdTList ifm;
- for (const VsmfieldsConfig::Documenttype::Index::Field & cf : ci.field) {
- LOG(spam, "Parsing field %s", cf.name.c_str());
- FieldSearchSpecMapT::const_iterator fIt, mIt;
- for (fIt=specMap().begin(), mIt=specMap().end(); (fIt != mIt) && (fIt->second.name() != cf.name); fIt++);
- if (fIt != mIt) {
- ifm.push_back(fIt->second.id());
- } else {
- LOG(warning, "Field %s not defined. Ignoring....", cf.name.c_str());
- }
- }
- indexMapp[ci.name] = ifm;
+ indexMapp[ci.name] = buildFieldSet(ci, specMap(), di.index);
}
_documentTypeMap[di.name] = indexMapp;
}