blob: 86cde64a1975aff068b2056b9130d752b68fb564 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "searchable.h"
#include "termasstring.h"
#include <vespa/searchlib/query/tree/intermediatenodes.h>
#include <vespa/searchlib/query/tree/queryvisitor.h>
#include <vespa/searchlib/query/tree/termnodes.h>
#include <vespa/searchlib/query/tree/simplequery.h>
#include <memory>
namespace search::queryeval {
class CreateBlueprintVisitorHelper : public query::QueryVisitor
{
private:
const IRequestContext & _requestContext;
Searchable & _searchable;
FieldSpec _field;
Blueprint::UP _result;
protected:
const IRequestContext & getRequestContext() const { return _requestContext; }
public:
CreateBlueprintVisitorHelper(Searchable &searchable, const FieldSpec &field, const IRequestContext & requestContext);
~CreateBlueprintVisitorHelper() override;
template <typename T>
void setResult(std::unique_ptr<T> result) { _result = std::move(result); }
Blueprint::UP getResult();
const FieldSpec &getField() const { return _field; }
void visitPhrase(query::Phrase &n);
template <typename WS, typename NODE>
void createWeightedSet(std::unique_ptr<WS> bp, NODE &n);
void visitWeightedSetTerm(query::WeightedSetTerm &n);
void visitDotProduct(query::DotProduct &n);
void visitWandTerm(query::WandTerm &n);
void visitNearestNeighborTerm(query::NearestNeighborTerm &n);
void handleNumberTermAsText(query::NumberTerm &n);
void illegalVisit() {}
void visit(query::And &) override { illegalVisit(); }
void visit(query::AndNot &) override { illegalVisit(); }
void visit(query::Equiv &) override { illegalVisit(); }
void visit(query::Near &) override { illegalVisit(); }
void visit(query::ONear &) override { illegalVisit(); }
void visit(query::Or &) override { illegalVisit(); }
void visit(query::Rank &) override { illegalVisit(); }
void visit(query::WeakAnd &) override { illegalVisit(); }
void visit(query::SameElement &) override { illegalVisit(); }
void visit(query::Phrase &n) override {
visitPhrase(n);
}
void visit(query::WeightedSetTerm &n) override { visitWeightedSetTerm(n); }
void visit(query::DotProduct &n) override { visitDotProduct(n); }
void visit(query::WandTerm &n) override { visitWandTerm(n); }
void visit(query::NumberTerm &n) override = 0;
void visit(query::LocationTerm &n) override = 0;
void visit(query::PrefixTerm &n) override = 0;
void visit(query::RangeTerm &n) override = 0;
void visit(query::StringTerm &n) override = 0;
void visit(query::SubstringTerm &n) override = 0;
void visit(query::SuffixTerm &n) override = 0;
void visit(query::RegExpTerm &n) override = 0;
void visit(query::NearestNeighborTerm &n) override = 0;
void visit(query::TrueQueryNode &) final override;
void visit(query::FalseQueryNode &) final override;
};
}
|