lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jamil Marques Figueira Junior <>
Subject How to know in the returned documents of a query had match in a specific field
Date Mon, 08 Jun 2009 20:51:29 GMT

    I wold like to know if any document returned from my search query had
match in a specific field. Example:

Field 1 - Company Name
Field 2 - Street

Document1 (CompanyName = "metalpack corp", Street = "Route 66")
Document2 (CompanyName = "ibi Bank", Street = "metalpack")

If I create a query like this:
BooleanQuery bq = new BooleanQuery();
TermQuery companyNameTermQuery = new TermQuery(new Term("CompanyName",
TermQuery streetTermQuery = new TermQuery(new Term("Street", "metalpack"))
bq.add(companyNameTermQuery, BooleanClause.Occur.SHOULD);
bq.add(streetTermQuery , BooleanClause.Occur.SHOULD);
IndexSearcher is = new IndexSearcher(myRAMDirectory);;

the query above will return both document of my index, but how can I know if
the result has documents that the matching field was the CompanyName without
read all the document results?



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