diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2017-03-07 16:15:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-07 16:15:55 +0100 |
commit | 00e4e7eb60b7bff9a25c927eac831476b583f414 (patch) | |
tree | a61215f39366024b142f38dcb47bcdb2a6efb1ae | |
parent | c4f67dc9afce7004576aad0745912a5ed1fbd061 (diff) | |
parent | 8245fa981c0ab802196dd4822aaba68b2707dcbf (diff) |
Merge pull request #1953 from yahoo/geirst/use-imported-fields-cfg-in-verify-rank-setup
Use imported fields config in verify rank setup.
-rw-r--r-- | searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp | 19 | ||||
-rw-r--r-- | searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp | 22 |
2 files changed, 34 insertions, 7 deletions
diff --git a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp index 6d950206a11..e1f2716ac16 100644 --- a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp +++ b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp @@ -4,10 +4,14 @@ LOG_SETUP("verify_ranksetup"); #include <vespa/config-attributes.h> +#include <vespa/config-imported-fields.h> #include <vespa/config-indexschema.h> #include <vespa/config-rank-profiles.h> #include <vespa/config/config.h> #include <vespa/config/helper/legacy.h> +#include <vespa/eval/eval/tensor_spec.h> +#include <vespa/eval/eval/value_cache/constant_value.h> +#include <vespa/eval/tensor/default_tensor_engine.h> #include <vespa/searchcommon/common/schemaconfigurer.h> #include <vespa/searchcore/config/config-ranking-constants.h> #include <vespa/searchcore/proton/matching/error_constant_value.h> @@ -15,9 +19,6 @@ LOG_SETUP("verify_ranksetup"); #include <vespa/searchlib/features/setup.h> #include <vespa/searchlib/fef/fef.h> #include <vespa/searchlib/fef/test/plugin/setup.h> -#include <vespa/eval/eval/tensor_spec.h> -#include <vespa/eval/eval/value_cache/constant_value.h> -#include <vespa/eval/tensor/default_tensor_engine.h> using config::ConfigContext; using config::ConfigHandle; @@ -27,6 +28,7 @@ using config::IConfigContext; using config::InvalidConfigException; using proton::matching::IConstantValueRepo; using vespa::config::search::AttributesConfig; +using vespa::config::search::ImportedFieldsConfig; using vespa::config::search::IndexschemaConfig; using vespa::config::search::RankProfilesConfig; using vespa::config::search::core::RankingConstantsConfig; @@ -50,7 +52,8 @@ public: bool verifyConfig(const RankProfilesConfig &rankCfg, const IndexschemaConfig &schemaCfg, const AttributesConfig &attributeCfg, - const RankingConstantsConfig &constantsCfg); + const RankingConstantsConfig &constantsCfg, + const ImportedFieldsConfig &importedFieldsCfg); int usage(); int Main(); @@ -103,12 +106,14 @@ bool App::verifyConfig(const RankProfilesConfig &rankCfg, const IndexschemaConfig &schemaCfg, const AttributesConfig &attributeCfg, - const RankingConstantsConfig &constantsCfg) + const RankingConstantsConfig &constantsCfg, + const ImportedFieldsConfig &importedFieldsCfg) { bool ok = true; search::index::Schema schema; search::index::SchemaBuilder::build(schemaCfg, schema); search::index::SchemaBuilder::build(attributeCfg, schema); + search::index::SchemaBuilder::build(importedFieldsCfg, schema); DummyConstantValueRepo repo(constantsCfg); for(size_t i = 0; i < rankCfg.rankprofile.size(); i++) { search::fef::Properties properties; @@ -154,12 +159,14 @@ App::Main() ConfigHandle<AttributesConfig>::UP attributesHandle = subscriber.subscribe<AttributesConfig>(cfgId); ConfigHandle<IndexschemaConfig>::UP schemaHandle = subscriber.subscribe<IndexschemaConfig>(cfgId); ConfigHandle<RankingConstantsConfig>::UP constantsHandle = subscriber.subscribe<RankingConstantsConfig>(cfgId); + ConfigHandle<ImportedFieldsConfig>::UP importedFieldsHandle = subscriber.subscribe<ImportedFieldsConfig>(cfgId); subscriber.nextConfig(); ok = verifyConfig(*rankHandle->getConfig(), *schemaHandle->getConfig(), *attributesHandle->getConfig(), - *constantsHandle->getConfig()); + *constantsHandle->getConfig(), + *importedFieldsHandle->getConfig()); } catch (ConfigRuntimeException & e) { LOG(error, "Unable to subscribe to config: %s", e.getMessage().c_str()); } catch (InvalidConfigException & e) { diff --git a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp index 29d3e5cdb1c..5d56966c920 100644 --- a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp +++ b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp @@ -50,7 +50,8 @@ struct Model { std::map<std::string,std::string> properties; std::map<std::string,std::string> constants; std::vector<bool> extra_profiles; - Model() : indexes(), attributes(), properties(), extra_profiles() { + std::vector<std::string> imported_attributes; + Model() : indexes(), attributes(), properties(), extra_profiles(), imported_attributes() { verify_dir(); } void index(const std::string &name, schema::DataType data_type, @@ -86,6 +87,9 @@ struct Model { void bad_profile() { extra_profiles.push_back(false); } + void imported_attribute(const std::string &name) { + imported_attributes.emplace_back(name); + } void write_attributes(const Writer &out) { out.fmt("attribute[%zu]\n", attributes.size()); std::map<std::string,std::pair<std::string,std::string> >::const_iterator pos = attributes.begin(); @@ -128,11 +132,21 @@ struct Model { ++idx; } } + void write_imported_attributes(const Writer &out) { + size_t idx = 0; + for (const auto &attr : imported_attributes) { + out.fmt("attribute[%zu].name \"%s\"\n", idx, attr.c_str()); + out.fmt("attribute[%zu].referencefield \"%s_ref\"\n", idx, attr.c_str()); + out.fmt("attribute[%zu].targetfield \"%s_target\"\n", idx, attr.c_str()); + ++idx; + } + } void generate() { write_attributes(Writer(gen_dir + "/attributes.cfg")); write_indexschema(Writer(gen_dir + "/indexschema.cfg")); write_rank_profiles(Writer(gen_dir + "/rank-profiles.cfg")); write_ranking_constants(Writer(gen_dir + "/ranking-constants.cfg")); + write_imported_attributes(Writer(gen_dir + "/imported-fields.cfg")); } bool verify() { generate(); @@ -166,6 +180,7 @@ struct SimpleModel : Model { index("list", schema::STRING, schema::ARRAY); index("keywords", schema::STRING, schema::WEIGHTEDSET); attribute("date", schema::INT32, schema::SINGLE); + imported_attribute("imported_attr"); constants["my_tensor"] = "tensor(x{},y{})"; } }; @@ -280,6 +295,11 @@ TEST_F("require that nested tensor join is not supported", SimpleModel()) { EXPECT_TRUE(!f.verify()); } +TEST_F("require that imported attribute field can be used by rank feature", SimpleModel()) { + f.first_phase("attribute(imported_attr)"); + EXPECT_TRUE(f.verify()); +} + //----------------------------------------------------------------------------- TEST_F("cleanup files", Model()) { |