aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/iqueryenvironment.h
blob: 7495bba8b3b99a9270b533d755fa6b556bc947cb (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "iindexenvironment.h"
#include "objectstore.h"
#include <vespa/searchcommon/attribute/iattributecontext.h>

namespace search::common { struct GeoLocationSpec; }

namespace search::fef {

class Properties;
class ITermData;

/**
 * Abstract view of query related information available to the
 * framework.
 **/
class IQueryEnvironment
{
public:
    /**
     * Convenience typedef.
     **/
    using SP = std::shared_ptr<IQueryEnvironment>;

    /** Convenience typedef. */
    using GeoLocationSpecPtrs = std::vector<const search::common::GeoLocationSpec *>;

    /**
     * Obtain the set of properties associated with this query
     * environment. This set of properties is known through the system
     * as 'rankProperties', and is tagged with the name 'rank' when
     * propagated down through the system.
     *
     * @return properties
     **/
    virtual const Properties &getProperties() const = 0;

    /**
     * Obtain the number of ranked terms in the query. The order of the
     * terms are not yet strongly defined.
     *
     * @return number of ranked terms in the query
     **/
    virtual uint32_t getNumTerms() const = 0;

    /**
     * Obtain information about a single ranked term in the query. If
     * idx is out of bounds, 0 will be returned.
     *
     * TODO: this must return an ordering that corresponds to the connexity of the term data.
     * TODO: any other ordering seems inappropriate when we offer connexity as an attribute of
     * TODO: the term data.
     *
     * @return information about a ranked term
     * @param idx the term we want information about
     **/
    virtual const ITermData *getTerm(uint32_t idx) const = 0;

    /**
     * Obtain the location information associated with this query environment.
     *
     * @return pointers to location objects.
     **/
    virtual GeoLocationSpecPtrs getAllLocations() const = 0;

    /**
     * Returns the attribute context for this query.
     *
     * @return attribute context
     **/
    virtual const search::attribute::IAttributeContext & getAttributeContext() const = 0;

    /**
     * Returns the average field length for the given field.
     *
     * @param field_name field name
     *
     * @return average field length
     **/
    virtual double get_average_field_length(const vespalib::string &field_name) const = 0;

    /**
     * Returns a const view of the index environment.
     *
     * @return index environment
     **/
    virtual const IIndexEnvironment & getIndexEnvironment() const = 0;

    /**
     * Virtual destructor to allow safe subclassing.
     **/
    virtual ~IQueryEnvironment() { }

    IObjectStore & getObjectStore() { return _objectStore; }
    const IObjectStore & getObjectStore() const { return _objectStore; }
protected:
    IQueryEnvironment() { }
private:
    ObjectStore _objectStore;
};

}