Switch branches/tags
QUERYDSL_20110111 QUERYDSL_20090609 QUERYDSL_20090528 QUERYDSL_20090521 QUERYDSL_20081212 QUERYDSL_4_2_1 QUERYDSL_4_2_0 QUERYDSL_4_1_4 QUERYDSL_4_1_3 QUERYDSL_4_1_2 QUERYDSL_4_1_1 QUERYDSL_4_1_0 QUERYDSL_4_0_9 QUERYDSL_4_0_8 QUERYDSL_4_0_7 QUERYDSL_4_0_6 QUERYDSL_4_0_5 QUERYDSL_4_0_4 QUERYDSL_4_0_3 QUERYDSL_4_0_2 QUERYDSL_4_0_1 QUERYDSL_4_0_0 QUERYDSL_3_7_4 QUERYDSL_3_7_3 QUERYDSL_3_7_2 QUERYDSL_3_7_1 QUERYDSL_3_7_0 QUERYDSL_3_6_9 QUERYDSL_3_6_8 QUERYDSL_3_6_7 QUERYDSL_3_6_6 QUERYDSL_3_6_5 QUERYDSL_3_6_4 QUERYDSL_3_6_3 QUERYDSL_3_6_2 QUERYDSL_3_6_1 QUERYDSL_3_6_0 QUERYDSL_3_5_1 QUERYDSL_3_5_0 QUERYDSL_3_4_3 QUERYDSL_3_4_2 QUERYDSL_3_4_1 QUERYDSL_3_4_0 QUERYDSL_3_3_4 QUERYDSL_3_3_3 QUERYDSL_3_3_2 QUERYDSL_3_3_1 QUERYDSL_3_3_0 QUERYDSL_3_3_0_BETA2 QUERYDSL_3_3_0_BETA1 QUERYDSL_3_2_4 QUERYDSL_3_2_3 QUERYDSL_3_2_2 QUERYDSL_3_2_1 QUERYDSL_3_2_0 QUERYDSL_3_1_1 QUERYDSL_3_1_0 QUERYDSL_3_0_0 QUERYDSL_3_0_0_BETA2 QUERYDSL_3_0_0_BETA1 QUERYDSL_2_9_0 QUERYDSL_2_8_2 QUERYDSL_2_8_1 QUERYDSL_2_8_0 QUERYDSL_2_7_2 QUERYDSL_2_7_1 QUERYDSL_2_7_0 QUERYDSL_2_6_0 QUERYDSL_2_5_0 QUERYDSL_2_3_3 QUERYDSL_2_3_2 QUERYDSL_2_3_1 QUERYDSL_2_3_0 QUERYDSL_2_2_5 QUERYDSL_2_2_4 QUERYDSL_2_2_3 QUERYDSL_2_2_2 QUERYDSL_2_2_1 QUERYDSL_2_2_0 QUERYDSL_2_2_0_BETA5 QUERYDSL_2_2_0_BETA4 QUERYDSL_2_2_0_BETA3 QUERYDSL_2_2_0_BETA2 QUERYDSL_2_2_0_BETA1 QUERYDSL_2_1_2 QUERYDSL_2_1_1 QUERYDSL_2_1_0 QUERYDSL_2_1_0_BETA3 QUERYDSL_2_1_0_BETA2 QUERYDSL_2_1_0_BETA1 QUERYDSL_2_1_0_BETA_1 QUERYDSL_2_0_9 QUERYDSL_2_0_8 QUERYDSL_2_0_7 QUERYDSL_2_0_6 QUERYDSL_2_0_5 QUERYDSL_2_0_4 QUERYDSL_2_0_3 QUERYDSL_2_0_2 QUERYDSL_2_0_0
Nothing to show
Find file History
Latest commit 8321eea Mar 21, 2018

README.md

Querydsl Lucene 4

The Lucene module provides integration with the Lucene 4 indexing library.

Maven integration

Add the following dependencies to your Maven project :

<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-lucene4</artifactId>
  <version>${querydsl.version}</version>
</dependency>

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.6.1</version>
</dependency>

Creating the query types

With fields year and title a manually created query type could look something like this:

public class QDocument extends EntityPathBase<Document>{
    private static final long serialVersionUID = -4872833626508344081L;
        
    public QDocument(String var) {
        super(Document.class, PathMetadataFactory.forVariable(var));
    }

    public final StringPath year = createString("year");

    public final StringPath title = createString("title");
}

QDocument represents a Lucene document with the fields year and title.

Code generation is not available for Lucene, since no schema data is available.

Querying

Querying with Querydsl Lucene is as simple as this:

QDocument doc = new QDocument("doc");

IndexSearcher searcher = new IndexSearcher(index);
LuceneQuery query = new LuceneQuery(true, searcher); 
List<Document> documents = query
    .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
    .fetch();

which is transformed into the following Lucene query :

+year:[1800 TO 2000] +title:huckle*

For more information on the Querydsl Lucene module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s05.html