lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Rowe <sar...@syr.edu>
Subject Re: Using Lucene to search log files
Date Mon, 11 Dec 2006 17:12:15 GMT
abdul aleem wrote:
> How to actually retrieve the content of search,
> 
> Most of the examples in Lucene in Action 
> Searcher gives the results found in number of
> documents 
> 
> but i coudln't find an API to retrieve the line or
> paragraph where the search is matched

Hi Abdul,

I don't know what your log files look like -- how have you defined your
Lucene document?  The document is the only level of granularity
available for returning hits in Lucene.

Something you should look at, though, is Mark Harwood's Highlighter
package, which is part of the Lucene Sandbox.  This package can be used
to break documents into fragments, to score those fragments based on a
supplied query, and then to highlight the terms from the query.  Below
is a link to the API docs:

http://lucene.apache.org/java/docs/api/org/apache/lucene/search/highlight/package-summary.html

You can find a description of using this package in "Lucene in Action",
in Section 8.7.

The Highlighter distribution .jar is packed inside of lucene-2.0.0.zip,
available from Apache mirrors:

http://www.apache.org/dyn/closer.cgi/lucene/java/

Also, the JUnit tests are a good place to see how to use this package:

https://svn.apache.org/repos/asf/lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java

Hope it helps,
Steve

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


Mime
View raw message