mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-06 21:05:50 +08:00
#705333 : added support for deep paths
This commit is contained in:
parent
f016abd54c
commit
46bc12b2c4
@ -33,6 +33,7 @@ import com.mysema.query.types.OrderSpecifier;
|
||||
import com.mysema.query.types.ParamExpression;
|
||||
import com.mysema.query.types.ParamNotSetException;
|
||||
import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.PathType;
|
||||
/**
|
||||
* Serializes Querydsl queries to Lucene queries.
|
||||
*
|
||||
@ -330,7 +331,14 @@ public class LuceneSerializer {
|
||||
}
|
||||
|
||||
protected String toField(Path<?> path) {
|
||||
return path.getMetadata().getExpression().toString();
|
||||
String rv = path.getMetadata().getExpression().toString();
|
||||
if (path.getMetadata().getParent() != null){
|
||||
Path<?> parent = path.getMetadata().getParent();
|
||||
if (parent.getMetadata().getPathType() != PathType.VARIABLE){
|
||||
rv = toField(parent) + "." + rv;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private void verifyArguments(Operation<?> operation) {
|
||||
|
||||
@ -14,8 +14,8 @@ import java.util.Arrays;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Field.Index;
|
||||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.document.Field.Index;
|
||||
import org.apache.lucene.document.Field.Store;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
|
||||
@ -31,21 +31,15 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.BooleanBuilder;
|
||||
import com.mysema.query.DefaultQueryMetadata;
|
||||
import com.mysema.query.MatchingFilters;
|
||||
import com.mysema.query.Module;
|
||||
import com.mysema.query.QueryMetadata;
|
||||
import com.mysema.query.StringConstant;
|
||||
import com.mysema.query.Target;
|
||||
import com.mysema.query.lucene.LuceneSerializer;
|
||||
import com.mysema.query.lucene.LuceneUtils;
|
||||
import com.mysema.query.lucene.QueryElement;
|
||||
import com.mysema.query.types.Expression;
|
||||
import com.mysema.query.types.expr.BooleanExpression;
|
||||
import com.mysema.query.types.path.NumberPath;
|
||||
import com.mysema.query.types.path.StringPath;
|
||||
import com.mysema.query.types.path.PathBuilder;
|
||||
import com.mysema.query.types.path.SimplePath;
|
||||
import com.mysema.query.types.path.StringPath;
|
||||
|
||||
/**
|
||||
* Tests for LuceneSerializer
|
||||
@ -194,6 +188,12 @@ public class LuceneSerializerTest {
|
||||
public void eq() throws Exception {
|
||||
testQuery(rating.eq("Good"), "rating:good", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eq_with_deep_path() throws Exception{
|
||||
StringPath deepPath = entityPath.get("property1", Object.class).getString("property2");
|
||||
testQuery(deepPath.eq("Good"), "property1.property2:good", 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fuzzyLike() throws Exception{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user