1Xapian::QueryParser(3)User Contributed Perl DocumentationXapian::QueryParser(3)
2
3
4

NAME

6       Search::Xapian::QueryParser - Parse a query string into a
7       Search::Xapian::Query object
8

DESCRIPTION

10       This module turns a human readable string into something Xapian can
11       understand.  The syntax supported is designed to be similar to other
12       web based search engines, so that users familiar with them don't have
13       to learn a whole new syntax.
14

SYNOPSIS

16         use Search::Xapian qw/:standard/;
17
18         my $qp = new Search::Xapian::QueryParser( [$database] );
19         $qp->set_stemmer(new Search::Xapian::Stem("english"));
20         $qp->set_default_op(OP_AND);
21
22         $database->enquire($qp->parse_query('a NEAR word OR "a phrase" NOT (too difficult) +eh'));
23

METHODS

25       new <database>
26           QueryParser constructor.
27
28       set_stemmer <stemmer>
29           Set the Search::Xapian::Stem object to be used for stemming query
30           terms.
31
32       set_stemming_strategy <strategy>
33           Set the stemming strategy.  Valid values are "STEM_ALL",
34           "STEM_SOME", "STEM_NONE".
35
36       set_stopper <stopper>
37           Set the Search::Xapian::Stopper object to be used for identifying
38           stopwords.
39
40       set_default_op <operator>
41           Set the default operator.
42
43           This operator is used to combine non-filter query items when no
44           explicit operator is used.
45
46           The most useful values for this are OP_OR (the default) and OP_AND.
47           OP_NEAR and OP_PHRASE can also be useful.
48
49           See Search::Xapian for descriptions of these constants.
50
51       get_default_op
52           Returns the current default operator.
53
54       set_database <database>
55           Pass a Search::Xapian::Database object which is used to check
56           whether terms exist in some situations.
57
58       parse_query <query_string> [<flags>]
59           Parses the query string according to the rules defined in the query
60           parser documentation below. You can specify certain flags to modify
61           the searching behaviour:
62
63             FLAG_BOOLEAN, FLAG_PHRASE, FLAG_LOVEHATE, FLAG_BOOLEAN_ANY_CASE,
64             FLAG_WILDCARD, FLAG_PURE_NOT, FLAG_PARTIAL, FLAG_SPELLING_CORRECTION,
65             FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, FLAG_AUTO_MULTIWORD_SYNONYMS
66
67           To specify multiple flags, "bitwise or" them together (with "|").
68           The default flags are "FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE"
69
70       add_prefix <field> <prefix>
71           Add a probabilistic term prefix.  E.g. $qp->add_prefix("author",
72           "A");
73
74           Allows the user to search for author:orwell which will search for
75           the term "Aorwel" (assuming English stemming is in use). Multiple
76           fields can be mapped to the same prefix (so you can e.g. make
77           title: and subject: aliases for each other).
78
79           Parameters: field     The user visible field name prefix    The
80           term prefix to map this to
81
82       add_boolean_prefix <field> prefix
83           Add a boolean term prefix allowing the user to restrict a search
84           with a boolean filter specified in the free text query.  E.g.
85
86             $p->add_boolean_prefix("site", "H");
87
88           Allows the user to restrict a search with site:xapian.org which
89           will be converted to Hxapian.org combined with any probabilistic
90           query with "OP_FILTER".
91
92           Multiple fields can be mapped to the same prefix (so you can e.g.
93           make site: and domain: aliases for each other).
94
95           Parameters: field     The user visible field name prefix    The
96           term prefix to map this to
97
98       stoplist_begin
99       stoplist_end
100       unstem_begin
101       unstem_end
102       get_description
103           Returns a string describing this object.
104
105       get_corrected_query_string
106           Get the spelling-corrected query string.
107
108           This will only be set if FLAG_SPELLING_CORRECTION is specified when
109           QueryParser::parse_query() was last called.
110
111           If there were no corrections, an empty string is returned.
112
113       set_max_wildcard_expansion <limit>
114           Specify the maximum expansion of a wildcard term.
115
116           Note: you must also set FLAG_WILDCARD for wildcard expansion to
117           happen.
118
119           Parameter limit is the maximum number of terms each wildcard in the
120           query can expand to, or 0 for no limit (which is the default).
121

REFERENCE

123         https://xapian.org/docs/queryparser.html
124         https://xapian.org/docs/sourcedoc/html/classXapian_1_1QueryParser.html
125
126
127
128perl v5.36.0                      2023-01-20            Xapian::QueryParser(3)
Impressum