xapian-core  1.4.21
queryparser_internal.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2005,2006,2007,2010,2011,2012,2013,2015,2016,2019 Olly Betts
5  * Copyright (C) 2010 Adam Sj√łgren
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22 
23 #ifndef XAPIAN_INCLUDED_QUERYPARSER_INTERNAL_H
24 #define XAPIAN_INCLUDED_QUERYPARSER_INTERNAL_H
25 
26 #include "xapian/intrusive_ptr.h"
27 #include <xapian/database.h>
28 #include <xapian/query.h>
29 #include <xapian/queryparser.h>
30 #include <xapian/stem.h>
31 
32 #include <list>
33 #include <map>
34 
35 using namespace std;
36 
37 class State;
38 
40 
42 struct FieldInfo {
45 
46  string grouping;
47 
49  vector<string> prefixes;
50 
53 
54  FieldInfo(filter_type type_, const string& prefix,
55  const string& grouping_ = string())
56  : type(type_), grouping(grouping_)
57  {
58  prefixes.push_back(prefix);
59  }
60 
62  const string& grouping_ = string())
63  : type(type_), grouping(grouping_), proc(proc_)
64  {
65  }
66 };
67 
68 namespace Xapian {
69 
70 class Utf8Iterator;
71 
72 struct RangeProc {
74  std::string grouping;
76 
77  RangeProc(RangeProcessor * range_proc, const std::string* grouping_)
78  : proc(range_proc),
79  grouping(grouping_ ? *grouping_ : std::string()),
80  default_grouping(grouping_ == NULL) { }
81 };
82 
84  friend class QueryParser;
85  friend class ::State;
90  const char * errmsg;
92  list<string> stoplist;
93  multimap<string, string> unstem;
94 
95  // Map "from" -> "A" ; "subject" -> "C" ; "newsgroups" -> "G" ;
96  // "foobar" -> "XFOO". FIXME: it does more than this now!
97  map<string, FieldInfo> field_map;
98 
99  list<RangeProc> rangeprocs;
100 
102 
104 
106 
108 
110 
111  void add_prefix(const string &field, const string &prefix);
112 
113  void add_prefix(const string &field, Xapian::FieldProcessor *proc);
114 
115  void add_boolean_prefix(const string &field, const string &prefix,
116  const string* grouping);
117 
118  void add_boolean_prefix(const string &field, Xapian::FieldProcessor *proc,
119  const string* grouping);
120 
121  std::string parse_term(Utf8Iterator &it, const Utf8Iterator &end,
122  bool cjk_ngram, bool &is_cjk_term,
123  bool &was_acronym);
124 
125  public:
126  Internal() : stem_action(STEM_SOME), stopper(NULL),
127  default_op(Query::OP_OR), errmsg(NULL),
128  max_wildcard_expansion(0), max_partial_expansion(100),
129  max_wildcard_type(Xapian::Query::WILDCARD_LIMIT_ERROR),
130  max_partial_type(Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT) { }
131 
132  Query parse_query(const string & query_string, unsigned int flags, const string & default_prefix);
133 };
134 
135 }
136 
137 #endif // XAPIAN_INCLUDED_QUERYPARSER_INTERNAL_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
This class is used to access a database, or a group of databases.
Definition: database.h:68
Class representing a stemming algorithm.
Definition: stem.h:62
op
Query operators.
Definition: query.h:78
map< string, FieldInfo > field_map
Build a Xapian::Query object from a user query string.
Definition: queryparser.h:778
STL namespace.
Xapian::Internal::opt_intrusive_ptr< RangeProcessor > proc
Xapian::Query API class.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
RangeProc(RangeProcessor *range_proc, const std::string *grouping_)
Information about how to handle a field prefix in the query string.
Base class for field processors.
Definition: queryparser.h:729
FieldInfo(filter_type type_, const string &prefix, const string &grouping_=string())
stem_strategy
Stemming strategies, for use with set_stemming_strategy().
Definition: queryparser.h:925
Parser State shared between the lexer and the parser.
API for working with Xapian databases.
vector< string > prefixes
Field prefix strings.
Base class for objects managed by intrusive_ptr.
Definition: intrusive_ptr.h:49
Base class for range processors.
Definition: queryparser.h:140
An iterator which returns Unicode character values from a UTF-8 encoded string.
Definition: unicode.h:38
Xapian::Internal::opt_intrusive_ptr< Xapian::FieldProcessor > proc
Field processor. Currently only one is supported.
multimap< string, string > unstem
Class representing a query.
Definition: query.h:46
FieldInfo(filter_type type_, Xapian::FieldProcessor *proc_, const string &grouping_=string())
Xapian::Internal::opt_intrusive_ptr< const Stopper > stopper
stemming algorithms
parsing a user query string to build a Xapian::Query object
filter_type type
The type of this field.