lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Berrettini" <...@jivesoftware.com>
Subject BooleanQuery
Date Thu, 13 Feb 2003 17:04:18 GMT
I'm having some trouble retrieving data I need from a combined query.

Here's what I'm trying to do: I want to search on several fields of my
documents and then return the best hits. I'm doing something like this:
            org.apache.lucene.search.Query bodyQuery =
                QueryParser.parse(queryString.toLowerCase(), "body",
analyzer);

            org.apache.lucene.search.Query subjectQuery =
                QueryParser.parse(queryString.toLowerCase(), "subject",
analyzer);

            org.apache.lucene.search.Query attachmentsQuery =
                QueryParser.parse(queryString.toLowerCase(),
"attachmentsText", analyzer);

            BooleanQuery bQuery = new BooleanQuery();
            bQuery.add(subjectQuery,false,false);
            bQuery.add(bodyQuery,false,false);
            bQuery.add(attachmentsQuery, false, false);

            Hits hits = searcher.search(comboQuery);

All well and good. But when I'm displaying the results, I want to know which
fields were responsible for the hit. It doesn't seem like this is something
that is available within in the hit. One option is to search again in all
hits for the field where this occurred. That doesn't seem efficient. Another
is to conduct several queries, but then merging the results becomes a little
problematic. Any recommendations of which way to go?

Jim


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message