Xapian:...ryParser(3)
hey bestie π welcome to the User Contributed Perl Documentation page for Xapian:...ryParser(3) β itβs giving parser glow-up, and weβre gonna read it together.
β¨ NAME β¨
Search::Xapian::QueryParser β parse a query string into a Search::Xapian::Query object. Periodt.
π¦ DESCRIPTION π¦
This module turns a human readable string into something Xapian can understand. The syntax supported is designed to be similar to other web based search engines, so that users familiar with them donβt have to learn a whole new syntax. iykyk π
π SYNOPSIS π
use Search::Xapian qw/:standard/;
my $qp = new Search::Xapian::QueryParser( [$database] );
$qp->set_stemmer(new Search::Xapian::Stem("english"));
$qp->set_default_op(OP_AND);
$database->enquire($qp->parse_query('a NEAR word OR "a phrase" NOT (too difficult) +eh'));
π METHODS π
new <database>β QueryParser constructor.set_stemmer <stemmer>β sets theSearch::Xapian::Stemobject to be used for stemming query terms.set_stemming_strategy <strategy>β sets the stemming strategy. Valid values are"STEM_ALL","STEM_SOME", and"STEM_NONE".set_stopper <stopper>β sets theSearch::Xapian::Stopperobject to be used for identifying stopwords.set_default_op <operator>β sets the default operator.- This operator is used to combine non-filter query items when no explicit operator is used.
- The most useful values for this are
OP_OR(the default) andOP_AND.OP_NEARandOP_PHRASEcan also be useful. - See
Search::Xapianfor descriptions of these constants.
get_default_opβ returns the current default operator.set_database <database>β pass aSearch::Xapian::Databaseobject which is used to check whether terms exist in some situations.parse_query <query_string> [<flags>]β parses the query string according to the rules defined in the query parser documentation below. You can specify certain flags to modify the searching behaviour:FLAG_BOOLEANFLAG_PHRASEFLAG_LOVEHATEFLAG_BOOLEAN_ANY_CASEFLAG_WILDCARDFLAG_PURE_NOTFLAG_PARTIALFLAG_SPELLING_CORRECTIONFLAG_SYNONYMFLAG_AUTO_SYNONYMSFLAG_AUTO_MULTIWORD_SYNONYMS- To specify multiple flags, bitwise or them together (with
|). The default flags areFLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE.
add_prefix <field> <prefix>β add a probabilistic term prefix. E.g.$qp->add_prefix("author", "A");- This allows the user to search for
author:orwell, which will search for the term"Aorwel"(assuming English stemming is in use). - Multiple fields can be mapped to the same prefix (so you can e.g. make
title:andsubject:aliases for each other). - Parameters: field β the user visible field name; prefix β the term prefix to map this to.
- This allows the user to search for
add_boolean_prefix <field> prefixβ add a boolean term prefix allowing the user to restrict a search with a boolean filter specified in the free text query. E.g.$p->add_boolean_prefix("site", "H");- This allows the user to restrict a search with
site:xapian.org, which will be converted toHxapian.orgcombined with any probabilistic query with"OP_FILTER". - Multiple fields can be mapped to the same prefix (so you can e.g. make
site:anddomain:aliases for each other). - Parameters: field β the user visible field name; prefix β the term prefix to map this to.
- This allows the user to restrict a search with
stoplist_begin,stoplist_end,unstem_begin,unstem_endβ these four are listed as methods; the page doesnβt add a description for them here.get_descriptionβ returns a string describing this object.get_corrected_query_stringβ get the spelling-corrected query string.- This will only be set if
FLAG_SPELLING_CORRECTIONis specified whenQueryParser::parse_query()was last called. - If there were no corrections, an empty string is returned.
- This will only be set if
set_max_wildcard_expansion <limit>β specify the maximum expansion of a wildcard term.
β οΈ note note note: you must also set FLAG_WILDCARD for wildcard expansion to happen. no cap.
- Parameter limit is the maximum number of terms each wildcard in the query can expand to, or
0for no limit (which is the default).
π REFERENCE π
https://xapian.org/docs/queryparser.html
https://xapian.org/docs/sourcedoc/html/classXapian_1_1QueryParser.html
okay bestie, thatβs the whole page β¨ the footer says perl v5.42.0, dated 2022-02-28, on Xapian:...ryParser(3) β mwah, go parse something iconic π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Search-Xapian 1.2.25.5-bp160.1.7 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Search-Xapian 1.2.25.5-bp160.1.7 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Search-Xapian 1.2.25.5-bp160.1.7 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Search-Xapian 1.2.25.5-bp160.1.7 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms