aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/features/terminfofeature.cpp
blob: 08d44f6092c3b782d20862d2b8b1aafa7d584c79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "terminfofeature.h"
#include "valuefeature.h"
#include <vespa/searchlib/fef/properties.h>
#include <vespa/searchlib/fef/featurenamebuilder.h>
#include <vespa/searchlib/fef/itermdata.h>
#include <vespa/vespalib/util/stash.h>

using namespace search::fef;
namespace search::features {

TermInfoBlueprint::TermInfoBlueprint()
    : Blueprint("termInfo"),
      _termIdx(0)
{
}

void
TermInfoBlueprint::visitDumpFeatures(const IIndexEnvironment &,
                                     IDumpFeatureVisitor &) const
{
}

bool
TermInfoBlueprint::setup(const IIndexEnvironment &,
                         const ParameterList & params)
{
    _termIdx = params[0].asInteger();
    describeOutput("queryidx", "The index of the first term with the given "
                   "term index in the query term ordering. -1 if not found.");
    return true;
}

FeatureExecutor &
TermInfoBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stash &stash) const
{
    feature_t queryIdx = -1.0;
    if (queryEnv.getNumTerms() > _termIdx) {
        queryIdx = _termIdx;
    }
    return stash.create<SingleValueExecutor>(queryIdx);
}

}