diff --git a/querydsl-lucene3/README.md b/querydsl-lucene3/README.md index b945b4c30..d47851e9b 100644 --- a/querydsl-lucene3/README.md +++ b/querydsl-lucene3/README.md @@ -5,36 +5,39 @@ The Lucene module provides integration with the Lucene 3 indexing library. **Maven integration** Add the following dependencies to your Maven project : - - - com.mysema.querydsl - querydsl-lucene3 - ${querydsl.version} - - - - org.slf4j - slf4j-log4j12 - 1.6.1 - +```XML + + com.mysema.querydsl + querydsl-lucene3 + ${querydsl.version} + + + + org.slf4j + slf4j-log4j12 + 1.6.1 + +``` **Creating the query types** With fields year and title a manually created query type could look something like this: - - public class QDocument extends EntityPathBase{ - 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"); + +```JAVA +public class QDocument extends EntityPathBase{ + 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. @@ -42,17 +45,21 @@ 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 IndexSearher(index); - LuceneQuery query = new LuceneQuery(true, searcher); - List documents = query - .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle")) - .list(); + +```JAVA +QDocument doc = new QDocument("doc"); + +IndexSearcher searcher = new IndexSearher(index); +LuceneQuery query = new LuceneQuery(true, searcher); +List documents = query + .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle")) + .list(); + ``` which is transformed into the following Lucene query : - - +year:[1800 TO 2000] +title:huckle* + +``` ++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