Skip to content

Commit a192da3

Browse files
authored
Merge pull request #35561 from vespa-engine/arnej/alternate-prop-names-for-nativeproximityfeature
Support alternate property names for native proximity
2 parents 9b8b5b3 + df16ebc commit a192da3

4 files changed

Lines changed: 36 additions & 12 deletions

File tree

searchlib/src/vespa/searchlib/features/elementwise_bm25_blueprint.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "elementwise_utils.h"
88
#include <vespa/eval/eval/fast_value.h>
99
#include <vespa/eval/eval/value_codec.h>
10-
#include <vespa/searchlib/fef/featurenamebuilder.h>
1110
#include <vespa/searchlib/fef/objectstore.h>
1211
#include <vespa/vespalib/util/stash.h>
1312

@@ -16,7 +15,6 @@ namespace search::features {
1615
using fef::AnyWrapper;
1716
using fef::Blueprint;
1817
using fef::FeatureExecutor;
19-
using fef::FeatureNameBuilder;
2018
using fef::FeatureType;
2119
using fef::FieldType;
2220
using fef::IQueryEnvironment;

searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "nativefieldmatchfeature.h"
44
#include "valuefeature.h"
55
#include "utils.h"
6+
#include <vespa/searchlib/fef/featurenamebuilder.h>
67
#include <vespa/searchlib/fef/fieldinfo.h>
78
#include <vespa/searchlib/fef/indexproperties.h>
89
#include <vespa/searchlib/fef/itablemanager.h>
@@ -161,14 +162,26 @@ NativeFieldMatchBlueprint::setup(const IIndexEnvironment & env,
161162
{
162163
param.field = false;
163164
}
164-
Property afl = env.getProperties().lookup(getBaseName(), "averageFieldLength", info->name());
165+
std::string alt_name = FeatureNameBuilder()
166+
.baseName(getBaseName())
167+
.parameter(info->name())
168+
.buildName();
169+
170+
Property afl = env.getProperties().lookup(alt_name, "averageFieldLength");
171+
if (!afl.found()) {
172+
afl = env.getProperties().lookup(getBaseName(), "averageFieldLength", info->name());
173+
}
165174
if (afl.found()) {
166175
param.averageFieldLength = util::strToNum<uint32_t>(afl.get());
167176
}
168177

169-
param.firstOccImportance = util::strToNum<feature_t>
170-
(env.getProperties().lookup(getBaseName(), "firstOccurrenceImportance", info->name()).
171-
get(defaultFirstOccImportance));
178+
std::string alt_importance = env.getProperties()
179+
.lookup(alt_name, "firstOccurrenceImportance")
180+
.get(defaultFirstOccImportance);
181+
std::string importance = env.getProperties()
182+
.lookup(getBaseName(), "firstOccurrenceImportance", info->name())
183+
.get(alt_importance);
184+
param.firstOccImportance = util::strToNum<feature_t>(importance);
172185

173186
if (NativeRankBlueprint::useTableNormalization(env)) {
174187
const Table * fo = param.firstOccTable;

searchlib/src/vespa/searchlib/features/nativeproximityfeature.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "nativeproximityfeature.h"
44
#include "valuefeature.h"
55
#include "utils.h"
6+
#include <vespa/searchlib/fef/featurenamebuilder.h>
67
#include <vespa/searchlib/fef/fieldinfo.h>
78
#include <vespa/searchlib/fef/indexproperties.h>
89
#include <vespa/searchlib/fef/itablemanager.h>
@@ -220,9 +221,18 @@ NativeProximityBlueprint::setup(const IIndexEnvironment & env,
220221
{
221222
param.field = false;
222223
}
223-
param.proximityImportance = util::strToNum<feature_t>
224-
(env.getProperties().lookup(getBaseName(), "proximityImportance", info->name()).
225-
get(defaultProximityImportance));
224+
225+
std::string alt_name = FeatureNameBuilder()
226+
.baseName(getBaseName())
227+
.parameter(info->name())
228+
.buildName();
229+
std::string alt_importance = env.getProperties()
230+
.lookup(alt_name, "proximityImportance")
231+
.get(defaultProximityImportance);
232+
std::string importance = env.getProperties()
233+
.lookup(getBaseName(), "proximityImportance", info->name())
234+
.get(alt_importance);
235+
param.proximityImportance = util::strToNum<feature_t>(importance);
226236

227237
if (NativeRankBlueprint::useTableNormalization(env)) {
228238
const Table * fp = param.proximityTable;

searchlib/src/vespa/searchlib/features/utils.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
22

33
#include "utils.hpp"
4+
#include <vespa/searchlib/fef/featurenamebuilder.h>
45
#include <vespa/searchlib/fef/itablemanager.h>
56
#include <vespa/searchlib/fef/properties.h>
67
#include <vespa/searchlib/fef/itermdata.h>
@@ -150,12 +151,14 @@ const search::fef::Table *
150151
lookupTable(const search::fef::IIndexEnvironment & env, const std::string & featureName,
151152
const std::string & table, const std::string & fieldName, const std::string & fallback)
152153
{
154+
auto alt_name = FeatureNameBuilder().baseName(featureName).parameter(fieldName).buildName();
153155
std::string tn1 = env.getProperties().lookup(featureName, table).get(fallback);
154-
std::string tn2 = env.getProperties().lookup(featureName, table, fieldName).get(tn1);
155-
const search::fef::Table * retval = env.getTableManager().getTable(tn2);
156+
std::string tn2 = env.getProperties().lookup(alt_name, table).get(tn1);
157+
std::string tn3 = env.getProperties().lookup(featureName, table, fieldName).get(tn2);
158+
const search::fef::Table * retval = env.getTableManager().getTable(tn3);
156159
if (retval == nullptr) {
157160
LOG(warning, "Could not find the %s '%s' to be used for field '%s' in feature '%s'",
158-
table.c_str(), tn2.c_str(), fieldName.c_str(), featureName.c_str());
161+
table.c_str(), tn3.c_str(), fieldName.c_str(), featureName.c_str());
159162
}
160163
return retval;
161164
}

0 commit comments

Comments
 (0)