1KinoSearch1::QueryParseUrs:e:rQuCeornytPrairbsuetre(d3K)PienrolSeDaorccuhm1e:n:tQauteiroynParser::QueryParser(3)
2
3
4
6 KinoSearch1::QueryParser::QueryParser - transform a string into a Query
7 object
8
10 my $query_parser = KinoSearch1::QueryParser::QueryParser->new(
11 analyzer => $analyzer,
12 fields => [ 'bodytext' ],
13 );
14 my $query = $query_parser->parse( $query_string );
15 my $hits = $searcher->search( query => $query );
16
18 The QueryParser accepts search strings as input and produces Query
19 objects, suitable for feeding into KinoSearch1::Searcher.
20
21 Syntax
22 The following constructs are recognized by QueryParser.
23
24 • Boolean operators 'AND', 'OR', and 'AND NOT'.
25
26 • Prepented +plus and -minus, indicating that the labeled entity
27 should be either required or forbidden -- be it a single word, a
28 phrase, or a parenthetical group.
29
30 • Logical groups, delimited by parentheses.
31
32 • Phrases, delimited by double quotes.
33
34 • Field-specific terms, in the form of "fieldname:termtext". (The
35 field specified by fieldname will be used instead of the
36 QueryParser's default fields).
37
38 A field can also be given to a logical group, in which case it is
39 the same as if the field had been prepended onto every term in the
40 group. For example: "foo:(bar baz)" is the same as "foo:bar
41 foo:baz".
42
44 new
45 my $query_parser = KinoSearch1::QueryParser::QueryParser->new(
46 analyzer => $analyzer, # required
47 fields => [ 'bodytext' ], # required
48 default_boolop => 'AND', # default: 'OR'
49 );
50
51 Constructor. Takes hash-style parameters:
52
53 • analyzer - An object which subclasses
54 KinoSearch1::Analysis::Analyzer. This must be identical to the
55 Analyzer used at index-time, or the results won't match up.
56
57 • fields - the names of the fields which will be searched against.
58 Must be supplied as an arrayref.
59
60 • default_field - deprecated. Use "fields" instead.
61
62 • default_boolop - two possible values: 'AND' and 'OR'. The default
63 is 'OR', which means: return documents which match any of the query
64 terms. If you want only documents which match all of the query
65 terms, set this to 'AND'.
66
67 parse
68 my $query = $query_parser->parse( $query_string );
69
70 Turn a query string into a Query object. Depending on the contents of
71 the query string, the returned object could be any one of several
72 subclasses of KinoSearch1::Search::Query.
73
75 Copyright 2005-2010 Marvin Humphrey
76
78 See KinoSearch1 version 1.01.
79
80
81
82perl v5.32.1 2021-K0i1n-o2S7earch1::QueryParser::QueryParser(3)