blob: 2438cbf5a3bdbd7bd081084542e6ec67cc949c82 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <memory>
namespace search::query { class Node; }
namespace search::queryeval {
class Blueprint;
class IRequestContext;
class FieldSpec;
class FieldSpecList;
/**
* Abstract class extended by components to expose content that can be
* searched by a query term. A Searchable component supports searching
* in one or more named fields. The Blueprint created by a Searchable
* is an intermediate query representation that is later used to
* create the actual search iterators used to produce matches.
**/
class Searchable
{
protected:
/**
* Create a blueprint searching a single field.
*
* @return blueprint
* @param requestContext that belongs to the query
* @param field the field to search
* @param term the query tree term
**/
virtual std::unique_ptr<Blueprint> createBlueprint(const IRequestContext & requestContext,
const FieldSpec &field,
const search::query::Node &term) = 0;
public:
using SP = std::shared_ptr<Searchable>;
Searchable() = default;
/**
* Create a blueprint searching a set of fields. The default
* implementation of this function will create blueprints for
* individual fields and combine them with an OR blueprint.
*
* @return blueprint
* @param requestContext that belongs to the query
* @param fields the set of fields to search
* @param term the query tree term
**/
virtual std::unique_ptr<Blueprint> createBlueprint(const IRequestContext & requestContext,
const FieldSpecList &fields,
const search::query::Node &term);
virtual ~Searchable() = default;
};
}
|