lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akbar Devani" <akbar.dev...@valuelabs.net>
Subject Multipile field search
Date Wed, 14 Feb 2007 11:11:23 GMT
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