[ci] Test Tcl bindings for dragonfly/freebsd
[xapian.git] / xapian-applications / omega / query.h
blob6fa85df68d10dde159a187ae14411fac9ca02de9
1 /** @file
2 * @brief: Omega functions for running queries, etc.
3 */
4 /* Copyright (C) 2007,2011,2016,2018 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef OMEGA_INCLUDED_QUERY_H
22 #define OMEGA_INCLUDED_QUERY_H
24 #include <xapian.h>
26 #include <set>
27 #include <string>
28 #include <vector>
30 extern Xapian::Query::op default_op;
32 /** Information for mapping a docid to a DB parameter value and docid in that
33 * subset of databases.
35 * A DB parameter value could point to a stub database file which can list
36 * multiple shards, and in this case we have multiple SubDB objects with the
37 * same name, and then index and out_of allow us to map docids.
39 class SubDB {
40 std::string name;
41 size_t index;
42 size_t out_of;
44 public:
45 SubDB(const std::string& name_,
46 size_t index_,
47 size_t out_of_)
48 : name(name_), index(index_), out_of(out_of_) { }
50 const std::string& get_name() const { return name; }
52 Xapian::docid map_docid(Xapian::docid did) const {
53 return (did - 1) * out_of + index + 1;
57 extern std::vector<SubDB> subdbs;
59 void add_bterm(const std::string & term);
61 void add_nterm(const std::string & term);
63 void add_date_filter(const string& date_start,
64 const string& date_end,
65 const string& date_span,
66 Xapian::valueno date_value_slot);
68 void add_query_string(const std::string& prefix, const std::string& s);
70 void parse_omegascript();
72 std::string pretty_term(std::string term);
74 class OmegaExpandDecider : public Xapian::ExpandDecider {
75 Xapian::Database db;
76 std::set<std::string> exclude_stems;
77 public:
78 OmegaExpandDecider(const Xapian::Database& db_,
79 std::set<std::string>* querytermset = NULL);
80 bool operator()(const std::string& term) const override;
83 std::string html_escape(const std::string &str);
85 #endif // OMEGA_INCLUDED_QUERY_H