aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.h
blob: bf99a6b1950e1defd5a5be82f1fe08c6fa40563e (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
46
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/common/matching_elements.h>
#include <vespa/searchlib/common/matching_elements_fields.h>
#include <vespa/vespalib/util/featureset.h>
#include <vector>
#include <memory>

namespace proton::matching {

class MatchToolsFactory;
class SearchSession;

/**
 * Used to perform additional matching related to a docsum
 * request. Note that external objects must be kept alive by the one
 * using this class.
 **/
class DocsumMatcher
{
private:
    using FeatureSet = vespalib::FeatureSet;
    using MatchingElementsFields = search::MatchingElementsFields;
    using MatchingElements = search::MatchingElements;

    std::shared_ptr<SearchSession>     _from_session;
    std::unique_ptr<MatchToolsFactory> _from_mtf;
    MatchToolsFactory    *_mtf;
    std::vector<uint32_t> _docs;

public:
    DocsumMatcher();
    DocsumMatcher(std::shared_ptr<SearchSession> session, std::vector<uint32_t> docs);
    DocsumMatcher(std::unique_ptr<MatchToolsFactory> mtf, std::vector<uint32_t> docs);
    ~DocsumMatcher();

    using UP = std::unique_ptr<DocsumMatcher>;

    FeatureSet::UP get_summary_features() const;
    FeatureSet::UP get_rank_features() const;
    MatchingElements::UP get_matching_elements(const MatchingElementsFields &fields) const;
};

}