I'm currently on 1.0.2 and the matching Search::Xapian perl modules. I input the following and the queryparser somehow doesn't seem to be detecting the operators? Am I missing something? Thanks, Eric INPUT: a word OR two NEAR "a phrase" NOT (too difficult) +eh PARSED: Xapian::Query((Za:(pos=1) AND Zword:(pos=2) AND or:(pos=3) AND Ztwo:(pos=4) AND near:(pos=5) AND Za:(pos=6) AND phrase:(pos=7) AND not:(pos=8) AND Ztoo:(pos=9) AND Zdifficult:(pos=10) AND Zeh:(pos=11))) #!/usr/bin/perl use Search::Xapian qw(:standard); my $dbpath = '/path/to/db'; my $query = 'a word OR two NEAR "a phrase" NOT (too difficult) +eh'; print "INPUT: $query\n\n"; my $db = Search::Xapian::Database->new($dbpath) || die "Could not open"; my $stemmer = Search::Xapian::Stem->new('english'); my $qp = new Search::Xapian::QueryParser( $db ); $qp->set_stemmer($stemmer); $qp->set_default_op(OP_AND); $qp->set_stemming_strategy(STEM_SOME); my $q = $qp->parse_query($query); print "PARSED: " . $q->get_description . "\n";
Eric Parusel
2007-Jul-24 16:22 UTC
[Xapian-discuss] Re: QueryParser problems? (from Perl?)
Hello, Should I be putting this in a bug report? Is this something that others can replicate? Thanks, Eric On 7/22/07, Eric Parusel <ericparusel@gmail.com> wrote:> I'm currently on 1.0.2 and the matching Search::Xapian perl modules. > > I input the following and the queryparser somehow doesn't seem to be > detecting the operators? > Am I missing something? > > Thanks, > Eric > > > > INPUT: a word OR two NEAR "a phrase" NOT (too difficult) +eh > > PARSED: Xapian::Query((Za:(pos=1) AND Zword:(pos=2) AND or:(pos=3) AND > Ztwo:(pos=4) AND near:(pos=5) AND Za:(pos=6) AND phrase:(pos=7) AND > not:(pos=8) AND Ztoo:(pos=9) AND Zdifficult:(pos=10) AND > Zeh:(pos=11))) > > > #!/usr/bin/perl > use Search::Xapian qw(:standard); > > my $dbpath = '/path/to/db'; > my $query = 'a word OR two NEAR "a phrase" NOT (too difficult) +eh'; > print "INPUT: $query\n\n"; > > my $db = Search::Xapian::Database->new($dbpath) || die "Could not open"; > > my $stemmer = Search::Xapian::Stem->new('english'); > > my $qp = new Search::Xapian::QueryParser( $db ); > $qp->set_stemmer($stemmer); > $qp->set_default_op(OP_AND); > $qp->set_stemming_strategy(STEM_SOME); > > my $q = $qp->parse_query($query); > print "PARSED: " . $q->get_description . "\n"; >
On Sun, Jul 22, 2007 at 01:11:17AM -0700, Eric Parusel wrote:> INPUT: a word OR two NEAR "a phrase" NOT (too difficult) +ehThis example (from the pod documentation) is bogus. You can't currently do NEAR on a phrase. I'll change the example to one which actually works. On Wed, Jul 25, 2007 at 12:23:01PM -0700, Eric Parusel wrote:> I just put in an int (not a reference to an array) to signify the > flags I wanted :s > > # FLAG_BOOLEAN,PHRASE,LOVEHATE > $qp->parse_query($query,7); *shrug*It's bad to hardwire numeric values for manifest constants into your scripts as they are an implementation detail and could change in the future (it's bad that the pod documentation even mentions them - I've fixed that in SVN). To specify multiple flags, combine them with bitwise OR (|) - the documentation now mentions that too. Cheers, Olly