Category: ‘Lucene’

Lucene Query Syntax for SQL

Aug 02 2011

Lucene provides a rich query syntax allowing users to easily create simple queries and scale up to complex ones. A number of search back-ends are built on top of Lucene nowadays such as ElasticSearch and Solr. In this article we will explore using Lucene’s query syntax against relational databases. We used Groovy here, but it […]

Highlight text using Lucene

Mar 06 2011

The following code illustrates how to use the Lucene highlighter to highlight text in any String. import; import; import; import; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.queryParser.QueryParser; import; import; import; import org.apache.lucene.util.Version; public class LuceneHighlighter { public static String highlight(String pText, String pQuery) throws Exception { Analyzer analyzer = […]