lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulo Silveira" <paulo.silve...@caelum.com.br>
Subject Re: MultiFieldQueryParser.parse deprecated. What can I use?
Date Thu, 27 Jul 2006 15:53:05 GMT
Ok, I just tested it.

So consider:
		String string = "word -foo";
		String[] fields = { "title", "body" };

For the MultField I have:

MultiFieldQueryParser qp = new MultiFieldQueryParser(fields,
SearchEngine.ANALYZER);
Query fieldsQuery = qp.parse(string);
System.out.println(fieldsQuery);

> (title:word body:word) -(title:foo body:foo)

And for the boolean:

BooleanQuery fieldsQuery = new BooleanQuery();
for (String field : fields) {
	QueryParser qp = new QueryParser(field, SearchEngine.ANALYZER);
	fieldsQuery.add(qp.parse(string), BooleanClause.Occur.SHOULD);
}
System.out.println(fieldsQuery);

> (title:word -title:foo) (body:word -body:foo)

quite different!!

On 7/26/06, Doron Cohen <DORONC@il.ibm.com> wrote:
> By the resulted query toString(), boolean query would not work correctly:
>
> qtxt:  a foo
> [1]  Multi Field Query (OR) : (title:a body:a) (title:foo body:foo)
> [2]  Multi Field Query (AND): +(title:a body:a) +(title:foo body:foo)
> [3]  Boolean Query          : (title:a title:foo) (body:a body:foo)
> --> By a chance, all are equivalent, returning doc1.
>
> qtxt:  a -foo
> [1]  Multi Field Query (OR) : (title:a body:a) -(title:foo body:foo)
> [2]  Multi Field Query (AND): +(title:a body:a) -(title:foo body:foo)
> [3]  Boolean Query          : (title:a -title:foo) (body:a -body:foo)
> --> Here [1,2] "correctly" return no docs, but [3] returns doc1.
>
> qtxt:  +a +foo
> [1]  Multi Field Query (OR) : +(title:a body:a) +(title:foo body:foo)
> [2]  Multi Field Query (AND): +(title:a body:a) +(title:foo body:foo)
> [3]  Boolean Query          : (+title:a +title:foo) (+body:a +body:foo)
> --> Now [1,2] "correctly" return doc1, but [3] returns no docs.
>
> qtxt:  a +foo
> [1]  Multi Field Query (OR) : (title:a body:a) +(title:foo body:foo)
> [2]  Multi Field Query (AND): +(title:a body:a) +(title:foo body:foo)
> [3]  Boolean Query          : (title:a +title:foo) (body:a +body:foo)
> --> All "correctly" return doc1.
>
> - Doron
>
> Daniel Noll <daniel@nuix.com.au> wrote on 25/07/2006 23:11:15:
>
> > Marvin Humphrey wrote:
> > > I believe that this will cause difficulties with prohibited terms.  Say
>
> > > you have these two documents...
> > >
> > >     Doc 1:
> > >        title: a
> > >        body:  foo
> > >     Doc 2:
> > >        title: b
> > >        body:  bar
> >
> > It's not just prohibited terms.  Happens for required terms too.  A
> > search for "a AND foo" would return no hits there even though it's a hit.
> >
> > Daniel
> >
> >
> > --
> > Daniel Noll
> >
> > Nuix Pty Ltd
> > Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
> > Web: http://www.nuix.com.au/                        Fax: +61 2 9212 6902
> >
> > This message is intended only for the named recipient. If you are not
> > the intended recipient you are notified that disclosing, copying,
> > distributing or taking any action in reliance on the contents of this
> > message or attachment is strictly prohibited.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Paulo E. A. Silveira
Caelum Ensino e Soluções em Java
http://www.caelum.com.br/

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message