[Xapian-discuss] query syntax?

Torsten Foertsch torsten.foertsch at gmx.net
Thu Nov 6 13:11:02 GMT 2008


On Thu 06 Nov 2008, Torsten Foertsch wrote:
> I am a bit confused about query syntax if wildcard queries are
> allowed. The code looks like:
>
>   my $query=$qp->parse_query( $qstring, FLAG_WILDCARD );
>   printf "Parsed query '%s'\n", $query->get_description();
>
> $qstring is "besteigung AND muench"
>
> If the wildcard flag is set $qstring is parsed as:
>
>   Xapian::Query((Zbesteig:(pos=1) OR and:(pos=2) OR Zmuench:(pos=3)))
>
> without FLAG_WILDCARD I get this:
>
>   Xapian::Query((Zbesteig:(pos=1) AND Zmuench:(pos=2)))
>
> That means the wildcard flag turns "AND" from an operator into a
> search word. Is that on purpose?

Found it myself. The Search::Xapian perl module is the culprit. 
XS/QueryParser.xs reads:

Query *
QueryParser::parse_query(q, flags = 7)
    string q
    int flags
    CODE:
	try {
	    RETVAL = new Query(THIS->parse_query(q,flags));
	} catch (const Error &error) {
	    croak( "Exception: %s", error.get_msg().c_str() );
	}
    OUTPUT:
	RETVAL

So, flags is 7 if not otherwise specified. If the queryparser is called 
as

  my $query=$qp->parse_query( $qstring, 7|FLAG_WILDCARD );

it works.

Now I have to figure out what these 3 bits mean.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch at gmx.net



More information about the Xapian-discuss mailing list