lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mohammad Norouzi" <mnr...@gmail.com>
Subject Re: Multipile field search
Date Wed, 14 Feb 2007 11:59:03 GMT
Hi,
I think it makes sense if it returns zero records because you are using
BooleanClause.Occur.SHOULD for each field, it means the term "open" should
occurs in all fields. but when you specify the field name in your query you
limit searching through that mentioned field.

as stated in Lucene javadoc the usage is:

String[] fields = {"filename", "contents", "description"};
 int[] flags = {MultiFieldQueryParser.NORMAL FIELD,
                MultiFieldQueryParser.REQUIRED FIELD,
                MultiFieldQueryParser.PROHIBITED FIELD,};
parse(query, fields, flags, analyzer);


-- 
Regards,
Mohammad Norouzi



On 2/14/07, Akbar Devani <akbar.devani@valuelabs.net> wrote:
>
> Hi,
>
> I'm in need of your help.I was looking for how serach multiple fields
> using Lucene,in one of the mailing list I found your solution
> to the issue.
>
> Its working perfectly but I need to pass query as field:query
>
> If I pass only query its returing zero hits.
>
> Below is code I'm using.
>
> Please do help me out.
>
> Thanking you,
>
> Akbar Devani.
>
>
>
>
>
> String fields [] = {"Name","Claim Update","Paid Indemnity","Paid
> Expenses","O/S Indemnity","O/S Expenses",
>
>                                     "Incurred"," Status","Date / Added
> by","Name","Paid Premium","Estimated","Premium
> Status","File","Detail","Comment","Comments" };
>
>
>
>                         BooleanClause.Occur[] flags = new
> BooleanClause.Occur[fields.length];
>
>
>
>      Query query = null;
>
>             try
>
>             {
>
>             for (int i =0 ; i < fields.length ; i++)
>
>                         {
>
>                         flags[i]=BooleanClause.Occur.SHOULD;
>
>
>
>                         }
>
>                         query = MultiFieldQueryParser.parse(expression,
> fields, flags, new StandardAnalyzer());
>
>             System.out.println("query:"+query.toString() );
>
>             //Log pasted below
>
>
>
>
>
>                          }
>
>     catch (ParseException e)
>
>     {
>
>         log.error("Unable to make any sense of the query", e);
>
>     }
>
> //Searching
>
>     try
>
>             {
>
>
>
>          IndexReader reader = IndexReader.open(ds.getRootPath
> (SERVLET_INDEX));
>
>          IndexSearcher searcher = new IndexSearcher(reader);
>
>          Hits hits = searcher.search(query);
>
>
>
>
>
>
>
>
>
> If I'm searching status:open its returing records where as if I'm
> searching only open its returing zero.
>
> Query Object Returned by MultiFieldQueryParser
>
>
>
>
>
> query:open
>
>
>
> Comment:open  Comments:open  Currency:open  Estimated
> Premium:open  Outstanding Adjuster:open
>
> Outstanding Expert:open  Outstanding Indemnity:open  Outstanding
> Lawyers:open  Outstanding Other:op
>
> en  Outstanding TPA:open  Paid Adjuster:open  Paid Expert:open  Paid
> Ind:open  Paid Lawyers:open  Pa
>
> id Movement Expert:open  Paid Other:open  Paid Premium:open  Paid
> TPA:open  Paid movement adjusters:
>
> open  Paid movement indemnity:open  Paid movement lawyers:open  Paid
> movement other:open  Transactio
>
> n reference:open  claim update:open  client:open  estimated
> premium:open  incurred:open  name:open
>
> o/s expenses:open  o/s indemnity:open  paid expenses:open  paid
> indemnity:open  paid premium:open  p
>
> lacing:open  producer:open  status:open
>
>
>
>
>
>

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