aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/juniper/queryhandle.h
blob: 6e50d85507a24fc26ac794d78867aa53ddbd3f16 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/* $Id$ */

#pragma once

/* Juniper internal interface */

class Matcher;
class MatchObject;

#include <vector>
#include "queryvisitor.h"
#include "expcache.h"

using queryterm_vector = std::vector<QueryTerm*>;
using querynode_vector = std::vector<QueryNode*>;

namespace juniper
{

/** Juniper internal definition of the query handle
 *  The query handle keeps a (default) match object for that query
 *  and possibly a set of additional match objects for expanded queries
 *  based on available expanders.
 *  Which matchobject to use for a result is then determined
 *  by the language ID.
 */

class QueryHandle
{
public:
    QueryHandle(const IQuery& fquery, const char* options, QueryModifier & modifier);
    ~QueryHandle();

    void SetSimpleQuery(Matcher* m);
    inline void SetPrivileged(bool priv) { _privileged_port = priv; }
    inline bool Privileged() { return _privileged_port; }
    inline void SetLog(uint32_t mask) { _log_mask = mask; }

    /** Find the currect match object to use for this language and query */
    MatchObject* MatchObj(uint32_t langid);

    /** Inform handle that there are expansions */
    void SetExpansions();
    /** Inform handle that there are reductions */
    void SetReductions();
protected:
    void parse_parameters(const char* options);
private:
    MatchObject* _mo; // The default MatcherObject
    bool _privileged_port;

    QueryHandle(QueryHandle &);
    QueryHandle &operator=(QueryHandle &);
public:
    // optional per query parameter override settings
    // (default (-1) means use configured value, other value forces override)
    int _dynsum_len;
    int _max_matches;
    int _surround_max;
    int _stem_extend;
    int _stem_min;
    int64_t _winsize;
    double _winsize_fallback_multiplier;
    int64_t _max_match_candidates;
    std::string _querytext; // an optional query string to use to override the input query
    ExpansionCache* _expansion_cache;

    // parameter settings that are taken directly from
    // this handle (eg. not overrides for config settings)
    uint32_t _log_mask;
    int _options;   // query constraint bitmap as defined in querynode.h
    int _limit;     // WITHIN/NEAR limit by parameter
    bool _has_expansions; // If set, the query must be replaced by a language dependent expansion (?)
    bool _has_reductions;
};

void SetDebug(unsigned int mask);

}  // end namespace juniper