lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Abhishek Mallik <abhishek.mallik...@gmail.com>
Subject Re: Using MultiField query with Boost factor
Date Fri, 07 Jun 2013 14:48:18 GMT
I understand but how to handle the situation where A or B may be phrase and
present in both the fields.


On Fri, Jun 7, 2013 at 7:12 PM, Ian Lea <ian.lea@gmail.com> wrote:

> Take a look at BooleanQuery and the setBoost() call on Query, and
> BooleanClause.Occur for the MUST/SHOULD logic.
>
> Something along the lines of this pseudo code
>
> BooleanQuery bq = new BooleanQuery();
>
> Query titleq = xxx;
> titleq.setBoost(somevalue)
> bq.add(titleq, must|should)
>
> Query addressq = yyy
> addressq.setBoost(someothervalue)
> bq.add(addressq, ...)
>
> searcher.search(bq, ...)
>
>
> You might be able to do the whole thing with the query parser but once
> the logic gets more than trivial I always prefer to build the queries
> in code.  You can use the parser to generate the titleq, addressq etc.
> queries if that is appropriate.
>
> You can nest BooleanQuery instances if you need that level of if
> (this) but not (that or that) unless (whichever or whatever) except
> when ().  Which you might.
>
>
> --
> Ian.
>
>
>
> On Thu, Jun 6, 2013 at 7:05 AM, Abhishek Mallik
> <abhishek.mallik.cs@gmail.com> wrote:
> > I have indexed documents in Lucene based on three fields: *title*,
> *address*
> > , *city*. Now I want to build my query say, *C A B *so that I can
> retrieve
> > the documents as follows:
> >
> > *C* must be present in the *title* field of the documents and either *A*
> or
> > *B* must be present in either of *address* and *city *fields of the
> matched
> > documents. The documents that have A present in either of those fields
> > should get higher score or higher boost. Here *A*, *B*, *C* may be single
> > terms or phrases.
> >
> > I am new to Lucene. I do not have any experience of framing such complex
> > queries. So if anyone please help me to solve this I will be really
> > grateful. Thank you.
> >
> >
> > -Abhishek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message