XapianQueryParser

XapianQueryParser — Parse query strings

Functions

Properties

XapianDatabase * database Read / Write
XapianQueryOp default-op Read / Write
XapianStem * stemmer Read / Write
XapianStemStrategy stemming-strategy Read / Write
XapianStopper * stopper Read / Write

Types and Values

Object Hierarchy

    GEnum
    ╰── XapianStemStrategy
    GFlags
    ╰── XapianQueryParserFeature
    GObject
    ╰── XapianQueryParser

Description

XapianQueryParser is a class that can parse a query string and generate a XapianQuery instance from it.

XapianQueryParser can use a XapianStem to isolate the terms for the query, as well as use a database for wildcard expansion.

Functions

xapian_query_parser_new ()

XapianQueryParser *
xapian_query_parser_new (void);

Creates a new XapianQueryParser.

Returns

the newly created XapianQueryParser instance.

[transfer full]


xapian_query_parser_set_stemmer ()

void
xapian_query_parser_set_stemmer (XapianQueryParser *parser,
                                 XapianStem *stemmer);

Sets the stemmer for parser .

Parameters

parser

a XapianQueryParser

 

stemmer

a XapianStem

 

xapian_query_parser_get_corrected_query_string ()

char *
xapian_query_parser_get_corrected_query_string
                               (XapianQueryParser *parser);

Get the spelling-corrected query string.

This will only be set if XAPIAN_QUERY_PARSER_FEATURE_SPELLING_CORRECTION is specified when xapian_query_parser_parse_query_full() was last called.

If there were no corrections, an empty string is returned.

Parameters

parser

a XapianQueryParser

 

Returns

the corrected query string.

[transfer full]

Since: 1.2


xapian_query_parser_get_stopper ()

XapianStopper *
xapian_query_parser_get_stopper (XapianQueryParser *parser);

Retrieves the stopper set using xapian_query_parser_set_stopper().

Parameters

parser

a XapianQueryParser

 

Returns

the XapianStopper used by parser .

[transfer none]

Since: 1.2


xapian_query_parser_set_stemming_strategy ()

void
xapian_query_parser_set_stemming_strategy
                               (XapianQueryParser *parser,
                                XapianStemStrategy strategy);

Sets the stemming strategy for parser .

The stemming strategy is only used if parser uses a stemmer.

Parameters

parser

a XapianQueryParser

 

strategy

a XapianStemStrategy value

 

xapian_query_parser_set_database ()

void
xapian_query_parser_set_database (XapianQueryParser *parser,
                                  XapianDatabase *database);

Sets the database used by parser for wildcard expansion.

Parameters

parser

a XapianQueryParser

 

database

a XapianDatabase

 

xapian_query_parser_set_stopper ()

void
xapian_query_parser_set_stopper (XapianQueryParser *parser,
                                 XapianStopper *stopper);

Sets the stopper used by parser stop word elimination.

Parameters

parser

a XapianQueryParser

 

stopper

a XapianStopper

 

Since: 1.2


xapian_query_parser_set_default_op ()

void
xapian_query_parser_set_default_op (XapianQueryParser *parser,
                                    XapianQueryOp op);

Set the operator to use to combine non-filter query items when no explicit operator is used.

Parameters

parser

a XapianQueryParser

 

op

a XapianQueryOp value

 

Since: 1.4


xapian_query_parser_add_prefix ()

void
xapian_query_parser_add_prefix (XapianQueryParser *parser,
                                const char *field,
                                const char *prefix);

Adds a probabilistic term prefix.

For instance, calling:

1
xapian_query_parser_add_prefix (parser, "author", "A");

allows the user to search for author:Orwell, which will be converted to a search for Aorwell.

It is possible to map multiple fields to the same prefix, for instance title and subject.

It is possible to map the same field to multiple prefixes; the generated query will perform an OR operation on each term.

Parameters

parser

a XapianQueryParser

 

field

the user visible field name

 

prefix

the term prefix to map the field to

 

xapian_query_parser_add_boolean_prefix ()

void
xapian_query_parser_add_boolean_prefix
                               (XapianQueryParser *parser,
                                const char *field,
                                const char *prefix,
                                gboolean exclusive);

Adds a boolean term prefix to the query.

Parameters

parser

a XapianQueryParser

 

field

the user visible field name

 

prefix

the term prefix to map the field to

 

exclusive

if TRUE each document can have at most one term with the given prefix

 

xapian_query_parser_parse_query ()

XapianQuery *
xapian_query_parser_parse_query (XapianQueryParser *parser,
                                 const char *query_string,
                                 GError **error);

Parses a query string and generates a XapianQuery instance for it.

See also: xapian_query_parser_parse_query_full()

Parameters

parser

a XapianQueryParser

 

query_string

the query string

 

error

return location for a GError

 

Returns

the newly created XapianQuery instance.

[transfer full]


xapian_query_parser_parse_query_full ()

XapianQuery *
xapian_query_parser_parse_query_full (XapianQueryParser *parser,
                                      const char *query_string,
                                      XapianQueryParserFeature flags,
                                      const char *default_prefix,
                                      GError **error);

Parses query_string and creates a XapianQuery instance for it.

Parameters

parser

a XapianQuery

 

query_string

the query string

 

flags

a bitwise OR of XapianQueryParserFeature values

 

default_prefix

the default prefix for terms

 

error

return location for a GError

 

Returns

the newly created XapianQuery instance.

[transfer full]

Types and Values

enum XapianStemStrategy

Stemming strategies.

Members

XAPIAN_STEM_STRATEGY_STEM_NONE

do not perform any stemming

 

XAPIAN_STEM_STRATEGY_STEM_SOME

generate both stemmed and unstemmed terms

 

XAPIAN_STEM_STRATEGY_STEM_ALL

generate only stemmed terms, without the Z prefix

 

XAPIAN_STEM_STRATEGY_STEM_ALL_Z

generate only stemmed terms, with the Z prefix

 

enum XapianQueryParserFeature

Flags for xapian_query_parser_parse_query_full().

Members

XAPIAN_QUERY_PARSER_FEATURE_BOOLEAN

support AND, OR, etc as well as bracketed subexpressions

 

XAPIAN_QUERY_PARSER_FEATURE_PHRASE

support quoted phrases

 

XAPIAN_QUERY_PARSER_FEATURE_LOVEHATE

support + and -

 

XAPIAN_QUERY_PARSER_FEATURE_BOOLEAN_ANY_CASE

support AND, OR, etc. even if not in upper case

 

XAPIAN_QUERY_PARSER_FEATURE_WILDCARD

support right truncation, e.g. Xap*

 

XAPIAN_QUERY_PARSER_FEATURE_PURE_NOT

allow queries such as NOT apples

 

XAPIAN_QUERY_PARSER_FEATURE_PARTIAL

enable partial matching

 

XAPIAN_QUERY_PARSER_FEATURE_SPELLING_CORRECTION

enable spelling correction

 

XAPIAN_QUERY_PARSER_FEATURE_SYNONYM

enable synonym operator ~

 

XAPIAN_QUERY_PARSER_FEATURE_AUTO_SYNONYMS

enable automatic use of synonyms for single terms

 

XAPIAN_QUERY_PARSER_FEATURE_AUTO_MULTIWORD_SYNONYMS

enable automatic use of synonyms for single terms and groups of terms

 

XAPIAN_QUERY_PARSER_FEATURE_CJK_NGRAM

enable generation of n-grams from CJK text (Since: 1.4.0)

 

XAPIAN_QUERY_PARSER_FEATURE_DEFAULT

default flags

 

Property Details

The “database” property

  “database”                 XapianDatabase *

The XapianDatabase to be used for wildcard expansion.

Flags: Read / Write


The “default-op” property

  “default-op”               XapianQueryOp

The query operator used to combine non-filter query items when no explicit operator is used.

Flags: Read / Write

Default value: XAPIAN_QUERY_OP_OR


The “stemmer” property

  “stemmer”                  XapianStem *

The XapianStem instance to be used for stemming the query string.

Flags: Read / Write


The “stemming-strategy” property

  “stemming-strategy”        XapianStemStrategy

The stemming strategy to use with the XapianStem set with the “stemmer” property.

Flags: Read / Write

Default value: XAPIAN_STEM_STRATEGY_STEM_NONE


The “stopper” property

  “stopper”                  XapianStopper *

The XapianStopper to be used for dropping stop words

Flags: Read / Write

Since: 1.2