Improve javadocs for querydsl-lucene3/4

This commit is contained in:
Timo Westkämper 2015-05-02 22:49:41 +03:00
parent 59460d05cb
commit 7064ca4f27
22 changed files with 141 additions and 77 deletions

View File

@ -108,7 +108,7 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Create a filter for constraints defined in this query
*
* @return
* @return filter
*/
public Filter asFilter() {
return new QueryWrapperFilter(createQuery());
@ -122,8 +122,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Add a DuplicateFilter for the field of the given property path
*
* @param property
* @return
* @param property distinct property
* @return the current object
*/
public Q distinct(Path<?> property) {
return filter(new DuplicateFilter(serializer.toField(property)));
@ -132,8 +132,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Apply the given Lucene filter to the search results
*
* @param filter
* @return
* @param filter filter
* @return the current object
*/
@SuppressWarnings("unchecked")
public Q filter(Filter filter) {
@ -220,8 +220,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Set the given FieldSelector to the query
*
* @param fieldSelector
* @return
* @param fieldSelector field selector
* @return the current object
*/
@SuppressWarnings("unchecked")
public Q load(FieldSelector fieldSelector) {
@ -232,8 +232,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Load only the fields of the given paths
*
* @param paths
* @return
* @param paths fields to load
* @return the current object
*/
@SuppressWarnings("unchecked")
public Q load(Path<?>... paths) {

View File

@ -14,6 +14,8 @@
package com.querydsl.lucene3;
/**
* Thrown for case ignore usage
*
* @author tiwe
*
*/

View File

@ -31,9 +31,9 @@ public final class LuceneExpressions {
/**
* Create a fuzzy query
*
* @param path
* @param value
* @return
* @param path path
* @param value value to match
* @return condition
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value) {
Term term = new Term(path.getMetadata().getName(), value);
@ -43,10 +43,10 @@ public final class LuceneExpressions {
/**
* Create a fuzzy query
*
* @param path
* @param value
* @param minimumSimilarity
* @return
* @param path path
* @param value value to match
* @param minimumSimilarity a value between 0 and 1 to set the required similarity
* @return condition
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value, float minimumSimilarity) {
Term term = new Term(path.getMetadata().getName(), value);
@ -56,11 +56,11 @@ public final class LuceneExpressions {
/**
* Create a fuzzy query
*
* @param path
* @param value
* @param minimumSimilarity
* @param prefixLength
* @return
* @param path path
* @param value value to match
* @param minimumSimilarity a value between 0 and 1 to set the required similarity
* @param prefixLength length of common (non-fuzzy) prefix
* @return condition
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value,
float minimumSimilarity, int prefixLength) {

View File

@ -16,6 +16,8 @@ package com.querydsl.lucene3;
import com.querydsl.core.types.Operator;
/**
* Lucene specific operators
*
* @author tiwe
*
*/

View File

@ -19,7 +19,19 @@ import org.apache.lucene.search.IndexSearcher;
import com.google.common.base.Function;
/**
* LuceneQuery is a Querydsl query implementation for Lucene queries.
* {@code LuceneQuery} is a Querydsl query implementation for Lucene queries.
*
* <p>Example:</p>
*
* <pre>{@code
* 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();
* }</pre>
*
* @author vema
*/

View File

@ -13,22 +13,24 @@
*/
package com.querydsl.lucene3;
import javax.annotation.Nullable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.regex.Pattern;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.querydsl.core.QueryMetadata;
import com.querydsl.core.types.*;
import javax.annotation.Nullable;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.util.NumericUtils;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.querydsl.core.QueryMetadata;
import com.querydsl.core.types.*;
/**
* Serializes Querydsl queries to Lucene queries.
*
@ -431,8 +433,8 @@ public class LuceneSerializer {
/**
* template method, override to customize
*
* @param path
* @return
* @param path path
* @return field name
*/
protected String toField(Path<?> path) {
PathMetadata md = path.getMetadata();
@ -466,9 +468,9 @@ public class LuceneSerializer {
/**
* template method
*
* @param leftHandSide
* @param rightHandSide
* @return
* @param leftHandSide left hand side
* @param rightHandSide right hand side
* @return results
*/
protected String[] convert(Path<?> leftHandSide, Expression<?> rightHandSide, QueryMetadata metadata) {
if (rightHandSide instanceof Operation) {
@ -497,9 +499,9 @@ public class LuceneSerializer {
/**
* template method
*
* @param leftHandSide
* @param rightHandSide
* @return
* @param leftHandSide left hand side
* @param rightHandSide right hand side
* @return results
*/
protected String[] convert(Path<?> leftHandSide, Object rightHandSide) {
String str = rightHandSide.toString();
@ -510,7 +512,6 @@ public class LuceneSerializer {
if (str.equals("")) {
return new String[] { str };
} else {
// return StringUtils.split(str);
return Iterables.toArray(WS_SPLITTER.split(str), String.class);
}
} else {

View File

@ -17,7 +17,7 @@ import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.dsl.StringOperation;
/**
* PhraseElement represents the embedded String as a phrase
* {@code PhraseElement} represents the embedded String as a phrase
*
* @author tiwe
*

View File

@ -19,7 +19,7 @@ import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.dsl.BooleanOperation;
/**
* QueryElement wraps a Lucene Query
* {@code QueryElement} wraps a Lucene Query
*
* @author tiwe
*

View File

@ -27,7 +27,7 @@ import com.mysema.commons.lang.CloseableIterator;
import com.querydsl.core.QueryException;
/**
* ResultIterator is a {@link CloseableIterator} implementation for Lucene query results
* {@code ResultIterator} is a {@link CloseableIterator} implementation for Lucene query results
*
* @author tiwe
*

View File

@ -17,7 +17,7 @@ import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.dsl.StringOperation;
/**
* TermElement represents the embedded String as a term
* {@code TermElement} represents the embedded String as a term
*
* @author tiwe
*

View File

@ -19,17 +19,32 @@ import org.apache.lucene.search.IndexSearcher;
import com.google.common.base.Function;
/**
* TypedQuery is a typed query implementation for Lucene queries.
*
* {@code TypedQuery} is a typed query implementation for Lucene queries.
*
* <p>Converts Lucene documents to typed results via a constructor supplied transformer</p>
*
* @author laim
* @author tiwe
*/
public class TypedQuery<T> extends AbstractLuceneQuery<T, TypedQuery<T>> {
/**
* Create a new TypedQuery instance
*
* @param searcher index searcher
* @param transformer transformer to transform Lucene documents to result objects
*/
public TypedQuery(IndexSearcher searcher, Function<Document, T> transformer) {
super(searcher, transformer);
}
/**
* Create a new TypedQuery instance
*
* @param serializer serializer
* @param searcher index search
* @param transformer transformer to transform documents to result objects
*/
public TypedQuery(LuceneSerializer serializer, IndexSearcher searcher, Function<Document, T> transformer) {
super(serializer, searcher, transformer);
}

View File

@ -110,7 +110,7 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Create a filter for constraints defined in this querydsl
*
* @return
* @return filter
*/
public Filter asFilter() {
return new QueryWrapperFilter(createQuery());
@ -124,8 +124,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Add a DuplicateFilter for the field of the given property path
*
* @param property
* @return
* @param property distinct property
* @return the current object
*/
public Q distinct(Path<?> property) {
return filter(new DuplicateFilter(serializer.toField(property)));
@ -134,8 +134,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Apply the given Lucene filter to the search results
*
* @param filter
* @return
* @param filter filter
* @return the current object
*/
@SuppressWarnings("unchecked")
public Q filter(Filter filter) {
@ -222,8 +222,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Set the given fields to load
*
* @param fieldsToLoad
* @return
* @param fieldsToLoad fields to load
* @return the current object
*/
@SuppressWarnings("unchecked")
public Q load(Set<String> fieldsToLoad) {
@ -234,8 +234,8 @@ public abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>>
/**
* Load only the fields of the given paths
*
* @param paths
* @return
* @param paths fields to load
* @return the current object
*/
@SuppressWarnings("unchecked")
public Q load(Path<?>... paths) {

View File

@ -14,6 +14,8 @@
package com.querydsl.lucene4;
/**
* Thrown for case ignore usage
*
* @author tiwe
*
*/

View File

@ -15,6 +15,7 @@ package com.querydsl.lucene4;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.util.automaton.LevenshteinAutomata;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.BooleanExpression;
@ -31,9 +32,9 @@ public final class LuceneExpressions {
/**
* Create a fuzzy query
*
* @param path
* @param value
* @return
* @param path path
* @param value value to match
* @return condition
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value) {
Term term = new Term(path.getMetadata().getName(), value);
@ -43,10 +44,10 @@ public final class LuceneExpressions {
/**
* Create a fuzzy query
*
* @param path
* @param value
* @param maxEdits
* @return
* @param path path
* @param value value to match
* @param maxEdits must be &gt;= 0 and &lt;= {@link LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}.
* @return condition
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value, int maxEdits) {
Term term = new Term(path.getMetadata().getName(), value);
@ -56,11 +57,11 @@ public final class LuceneExpressions {
/**
* Create a fuzzy query
*
* @param path
* @param value
* @param maxEdits
* @param prefixLength
* @return
* @param path path
* @param value value to match
* @param maxEdits must be &gt;= 0 and &lt;= {@link LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}.
* @param prefixLength length of common (non-fuzzy) prefix
* @return condition
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value,
int maxEdits, int prefixLength) {

View File

@ -16,6 +16,8 @@ package com.querydsl.lucene4;
import com.querydsl.core.types.Operator;
/**
* Lucene specific operators
*
* @author tiwe
*
*/

View File

@ -19,7 +19,19 @@ import org.apache.lucene.search.IndexSearcher;
import com.google.common.base.Function;
/**
* LuceneQuery is a Querydsl query implementation for Lucene queries.
* {@code LuceneQuery} is a Querydsl query implementation for Lucene queries.
* <p>Example:</p>
*
* <pre>{@code
* 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();
* }</pre>
*
* @author vema
*/

View File

@ -434,8 +434,8 @@ public class LuceneSerializer {
/**
* template method, override to customize
*
* @param path
* @return
* @param path path
* @return field name
*/
protected String toField(Path<?> path) {
PathMetadata md = path.getMetadata();
@ -469,9 +469,9 @@ public class LuceneSerializer {
/**
* template method
*
* @param leftHandSide
* @param rightHandSide
* @return
* @param leftHandSide left hand side
* @param rightHandSide right hand side
* @return results
*/
protected String[] convert(Path<?> leftHandSide, Expression<?> rightHandSide, QueryMetadata metadata) {
if (rightHandSide instanceof Operation) {
@ -500,9 +500,9 @@ public class LuceneSerializer {
/**
* template method
*
* @param leftHandSide
* @param rightHandSide
* @return
* @param leftHandSide left hand side
* @param rightHandSide right hand side
* @return results
*/
protected String[] convert(Path<?> leftHandSide, Object rightHandSide) {
String str = rightHandSide.toString();

View File

@ -17,7 +17,7 @@ import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.dsl.StringOperation;
/**
* PhraseElement represents the embedded String as a phrase
* {@code PhraseElement} represents the embedded String as a phrase
*
* @author tiwe
*

View File

@ -19,7 +19,7 @@ import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.dsl.BooleanOperation;
/**
* QueryElement wraps a Lucene Query
* {@code QueryElement} wraps a Lucene Query
*
* @author tiwe
*

View File

@ -27,7 +27,7 @@ import com.mysema.commons.lang.CloseableIterator;
import com.querydsl.core.QueryException;
/**
* ResultIterator is a {@link CloseableIterator} implementation for Lucene query results
* {@code ResultIterator} is a {@link CloseableIterator} implementation for Lucene query results
*
* @author tiwe
*

View File

@ -17,7 +17,7 @@ import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.dsl.StringOperation;
/**
* TermElement represents the embedded String as a term
* {@code TermElement} represents the embedded String as a term
*
* @author tiwe
*

View File

@ -19,17 +19,32 @@ import org.apache.lucene.search.IndexSearcher;
import com.google.common.base.Function;
/**
* TypedQuery is a typed query implementation for Lucene queries.
* {@code TypedQuery} is a typed query implementation for Lucene queries.
*
* <p>Converts Lucene documents to typed results via a constructor supplied transformer</p>
*
* @author laim
* @author tiwe
*/
public class TypedQuery<T> extends AbstractLuceneQuery<T, TypedQuery<T>> {
/**
* Create a new TypedQuery instance
*
* @param searcher index searcher
* @param transformer transformer to transform Lucene documents to result objects
*/
public TypedQuery(IndexSearcher searcher, Function<Document, T> transformer) {
super(searcher, transformer);
}
/**
* Create a new TypedQuery instance
*
* @param serializer serializer
* @param searcher index searcher
* @param transformer transformer to transform Lucene documents to result objects
*/
public TypedQuery(LuceneSerializer serializer, IndexSearcher searcher, Function<Document, T> transformer) {
super(serializer, searcher, transformer);
}