summaryrefslogtreecommitdiffstats
path: root/streamingvisitors/src/vespa/searchvisitor/querytermdata.h
blob: 36176f70d1dce578697e31c9cb9ad8927f0c0954 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/fef/matchdatalayout.h>
#include <vespa/searchlib/fef/simpletermdata.h>
#include <vespa/searchlib/query/streaming/querynoderesultbase.h>

namespace streaming {

/**
 * This class keeps data for a query term that is used by the ranking framework.
 **/
class QueryTermData : public search::streaming::QueryNodeResultBase
{
private:
    search::fef::SimpleTermData   _termData;
public:
    QueryTermData * clone() const override { return new QueryTermData(); }
    search::fef::SimpleTermData &getTermData() noexcept { return _termData; }
};

class SearchMethodInfo {
public:
    virtual ~SearchMethodInfo() = default;
    virtual bool is_text_matching(vespalib::stringref index) const noexcept = 0;
};

class QueryTermDataFactory final : public search::streaming::QueryNodeResultFactory {
public:
    QueryTermDataFactory(const SearchMethodInfo * searchMethodInfo) noexcept : _searchMethodInfo(searchMethodInfo) {}
    std::unique_ptr<search::streaming::QueryNodeResultBase> create() const override {
        return std::make_unique<QueryTermData>();
    }
    bool getRewriteFloatTerms(vespalib::stringref index ) const noexcept override {
        return _searchMethodInfo && _searchMethodInfo->is_text_matching(index);
    }
private:
    const SearchMethodInfo * _searchMethodInfo;
};


} // namespace streaming