aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/query/tree/intermediatenodes.h
blob: 30160c3d532a2d2f9322a74fa675b9e95f263e1b (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "intermediate.h"
#include "querynodemixin.h"
#include "term.h"

namespace search::query {

class And : public QueryNodeMixin<And, Intermediate> {
public:
    virtual ~And() = 0;
};

//-----------------------------------------------------------------------------

class AndNot : public QueryNodeMixin<AndNot, Intermediate> {
public:
    virtual ~AndNot() = 0;
};

//-----------------------------------------------------------------------------

class Or : public QueryNodeMixin<Or, Intermediate> {
public:
    virtual ~Or() = 0;
};

//-----------------------------------------------------------------------------

class WeakAnd : public QueryNodeMixin<WeakAnd, Intermediate> {
    uint32_t _minHits;
    vespalib::string _view;
public:
    virtual ~WeakAnd() = 0;

    WeakAnd(uint32_t minHits, const vespalib::string & view) : _minHits(minHits), _view(view) {}

    uint32_t getMinHits() const { return _minHits; }
    const vespalib::string & getView() const { return _view; }
};

//-----------------------------------------------------------------------------

class Equiv : public QueryNodeMixin<Equiv, Intermediate> {
private:
    int32_t _id;
    Weight  _weight;
public:
    virtual ~Equiv() = 0;

    Equiv(int32_t id, Weight weight)
        : _id(id), _weight(weight)
    {}

    Weight getWeight() const { return _weight; }
    int32_t getId() const { return _id; }
};

//-----------------------------------------------------------------------------

class Rank : public QueryNodeMixin<Rank, Intermediate> {
public:
    virtual ~Rank() = 0;
};

//-----------------------------------------------------------------------------

class Near : public QueryNodeMixin<Near, Intermediate>
{
    uint32_t _distance;

 public:
    Near(size_t distance) : _distance(distance) {}
    virtual ~Near() = 0;

    size_t getDistance() const { return _distance; }
};

//-----------------------------------------------------------------------------

class ONear : public QueryNodeMixin<ONear, Intermediate>
{
    uint32_t _distance;

 public:
    ONear(size_t distance) : _distance(distance) {}
    virtual ~ONear() = 0;

    size_t getDistance() const { return _distance; }
};

//-----------------------------------------------------------------------------

class Phrase : public QueryNodeMixin<Phrase, Intermediate>, public Term {
public:
    Phrase(const vespalib::string &view, int32_t id, Weight weight)
        : Term(view, id, weight), _expensive(false) {}
    virtual ~Phrase() = 0;
    Phrase &set_expensive(bool value) {
        _expensive = value;
        return *this;
    }
    bool is_expensive() const { return _expensive; }
private:
    bool _expensive;
};

class SameElement : public QueryNodeMixin<SameElement, Intermediate>, public Term {
public:
    SameElement(const vespalib::string &view, int32_t id, Weight weight)
        : Term(view, id, weight), _expensive(false) {}
    virtual ~SameElement() = 0;
    SameElement &set_expensive(bool value) {
        _expensive = value;
        return *this;
    }
    bool is_expensive() const { return _expensive; }
private:
    bool _expensive;
};

}