Hi, 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? Can search operators be used together with wildcard searches? I am using 1.0.9. Thanks, Torsten
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();> That means the wildcard flag turns "AND" from an operator into a search > word. Is that on purpose?What's happening is that the default flag argument for parse_query() is "FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE". If you specify a set of flags manually, this default is overridden with the flags you specify.> Can search operators be used together with wildcard searches?Yes. Just replace FLAG_WILDCARD in your line with: FLAG_WILDCARD|FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE -- Richard
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