lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafael Cunha de Almeida <>
Subject Re: Can Lucene tells which field matched ?
Date Sat, 08 Nov 2008 21:42:23 GMT
On Thu, 6 Nov 2008 01:18:45 -0800 (PST)
Dora <> wrote:

> Hi 
> I am new to Lucene and working on a search module for some XML data:
> I need to provide a "search all" able to look in all xml fields.
> Apparently Lucene (2.4.0) does not provide such a "search all" facility, and
> I have to build a query with my search field associated to all available XML
> elements.
> Assuming that I am searching in a address book (fictive example for
> illustration) which is made of contacts (my lucene documents) containing
> several fields like name, address, city, ...
> So my search for "paul" inside my addressbook will look like:
> name:paul OR address:paul OR city:paul and so on... 
> Lucene will then tell me which contacts match my query, but is there a way
> to know which field(s) matched the request ?
> The goal is to display the XML with the matching fields highlighted.
> I did not found anything like this in Lucene, so I seems that the only way
> is to perform a additional search field by field...
> So if I have 100 fields per document (I told you my address book was a
> fictive example, the XML I am working on are a little bit more complex), and
> get 100 results that I want ot display in a list, this mean that I would
> need to perform 10000 additional searches request... 
> Please tell me that there is a better way to do the job...

My case is more or less similar, but I don't have that many fields. I
have been using MultiQueryFieldParser and then Highlighter to figure
out which fields have a match and then I get the relevant fragment with
the right term highlighter.

I have a question for you, though. Are you parsing the XML for each
document after you get the results of a query or are you using stored
fields? What XML parser are you using?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message