summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2022-06-08 12:08:42 +0000
committerGeir Storli <geirst@yahooinc.com>2022-06-08 14:24:49 +0000
commitfcb0aba51001a67d89559aca5cca25b5e93d830e (patch)
tree403f1897755b88646f172d058dcfd558d7ea98e7 /searchlib
parentbf4a9188b012a0db5b7be89758406f87fa41712c (diff)
Add bm25() and matches() and remove now() as default rank features to be dumped on Vespa 8.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/features/bm25/bm25_test.cpp6
-rw-r--r--searchlib/src/tests/features/prod_features.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/features/bm25_feature.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/features/matchesfeature.cpp13
-rw-r--r--searchlib/src/vespa/searchlib/features/nowfeature.cpp3
5 files changed, 31 insertions, 9 deletions
diff --git a/searchlib/src/tests/features/bm25/bm25_test.cpp b/searchlib/src/tests/features/bm25/bm25_test.cpp
index d3c812198e1..3a9dfffa8d7 100644
--- a/searchlib/src/tests/features/bm25/bm25_test.cpp
+++ b/searchlib/src/tests/features/bm25/bm25_test.cpp
@@ -94,6 +94,12 @@ TEST_F(Bm25BlueprintTest, blueprint_can_prepare_shared_state_with_average_field_
EXPECT_DOUBLE_EQ(10, as_value<double>(*store.get("bm25.afl.is")));
}
+TEST_F(Bm25BlueprintTest, dump_features_for_all_index_fields)
+{
+ FtTestApp::FT_DUMP(factory, "bm25", index_env,
+ StringList().add("bm25(is)").add("bm25(ia)").add("bm25(iws)"));
+}
+
struct Scorer {
double avg_field_length;
diff --git a/searchlib/src/tests/features/prod_features.cpp b/searchlib/src/tests/features/prod_features.cpp
index 2c04a326e3e..b213fd380d5 100644
--- a/searchlib/src/tests/features/prod_features.cpp
+++ b/searchlib/src/tests/features/prod_features.cpp
@@ -1473,7 +1473,7 @@ Test::testNow()
FT_SETUP_OK (pt, params, in, out.add("out"));
FT_SETUP_FAIL(pt, params.add("foo"));
- FT_DUMP(_factory, "now", StringList().add("now"));
+ FT_DUMP_EMPTY(_factory, "now");
}
{
@@ -1703,7 +1703,7 @@ Test::testMatches()
FT_SETUP_OK(pt, ft.getIndexEnv(), params.clear().add("bar"), in, out);
FT_SETUP_OK(pt, ft.getIndexEnv(), params.add("1"), in, out);
- FT_DUMP_EMPTY(_factory, "matches");
+ FT_DUMP(_factory, "matches", ft.getIndexEnv(), StringList().add("matches(foo)").add("matches(bar)"));
}
{ // Test executor for index fields
EXPECT_TRUE(assertMatches(0, "x", "a", "matches(foo)"));
diff --git a/searchlib/src/vespa/searchlib/features/bm25_feature.cpp b/searchlib/src/vespa/searchlib/features/bm25_feature.cpp
index 22b29014a81..66658fd2ca5 100644
--- a/searchlib/src/vespa/searchlib/features/bm25_feature.cpp
+++ b/searchlib/src/vespa/searchlib/features/bm25_feature.cpp
@@ -2,6 +2,7 @@
#include "bm25_feature.h"
#include "utils.h"
+#include <vespa/searchlib/fef/featurenamebuilder.h>
#include <vespa/searchlib/fef/itermdata.h>
#include <vespa/searchlib/fef/itermfielddata.h>
#include <vespa/searchlib/fef/objectstore.h>
@@ -18,7 +19,9 @@ namespace search::features {
using fef::AnyWrapper;
using fef::Blueprint;
using fef::FeatureExecutor;
+using fef::FeatureNameBuilder;
using fef::FieldInfo;
+using fef::FieldType;
using fef::ITermData;
using fef::ITermFieldData;
using fef::MatchDataDetails;
@@ -127,9 +130,14 @@ Bm25Blueprint::Bm25Blueprint()
void
Bm25Blueprint::visitDumpFeatures(const fef::IIndexEnvironment& env, fef::IDumpFeatureVisitor& visitor) const
{
- (void) env;
- (void) visitor;
- // TODO: Implement when feature is supported end-2-end with both memory and disk index.
+ for (uint32_t i = 0; i < env.getNumFields(); ++i) {
+ const auto* field = env.getField(i);
+ if (field->type() == FieldType::INDEX) {
+ FeatureNameBuilder fnb;
+ fnb.baseName(getBaseName()).parameter(field->name());
+ visitor.visitDumpFeature(fnb.buildName());
+ }
+ }
}
fef::Blueprint::UP
diff --git a/searchlib/src/vespa/searchlib/features/matchesfeature.cpp b/searchlib/src/vespa/searchlib/features/matchesfeature.cpp
index cbbb12e8314..07151e5ae1c 100644
--- a/searchlib/src/vespa/searchlib/features/matchesfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/matchesfeature.cpp
@@ -3,6 +3,7 @@
#include "matchesfeature.h"
#include "utils.h"
#include "valuefeature.h"
+#include <vespa/searchlib/fef/featurenamebuilder.h>
#include <vespa/searchlib/fef/fieldinfo.h>
#include <vespa/vespalib/util/stash.h>
@@ -75,9 +76,17 @@ MatchesBlueprint::MatchesBlueprint() :
}
void
-MatchesBlueprint::visitDumpFeatures(const IIndexEnvironment &,
- IDumpFeatureVisitor &) const
+MatchesBlueprint::visitDumpFeatures(const IIndexEnvironment& env,
+ IDumpFeatureVisitor& visitor) const
{
+ for (uint32_t i = 0; i < env.getNumFields(); ++i) {
+ const auto* field = env.getField(i);
+ if (field->type() == FieldType::INDEX || field->type() == FieldType::ATTRIBUTE) {
+ FeatureNameBuilder fnb;
+ fnb.baseName(getBaseName()).parameter(field->name());
+ visitor.visitDumpFeature(fnb.buildName());
+ }
+ }
}
bool
diff --git a/searchlib/src/vespa/searchlib/features/nowfeature.cpp b/searchlib/src/vespa/searchlib/features/nowfeature.cpp
index 49495612af3..21415555ceb 100644
--- a/searchlib/src/vespa/searchlib/features/nowfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/nowfeature.cpp
@@ -20,9 +20,8 @@ NowExecutor::execute(uint32_t) {
}
void
-NowBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &, fef::IDumpFeatureVisitor &visitor) const
+NowBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &, fef::IDumpFeatureVisitor &) const
{
- visitor.visitDumpFeature(getBaseName());
}
bool