mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Edited and added class documentation (author etc.)
This commit is contained in:
parent
a9582fb65d
commit
c2b809e661
@ -28,7 +28,7 @@ import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.expr.EBoolean;
|
||||
|
||||
/**
|
||||
* LuceneQuery is a Querydsl query implementation for Lucene queries
|
||||
* LuceneQuery is a Querydsl query implementation for Lucene queries.
|
||||
*
|
||||
* @author vema
|
||||
*/
|
||||
|
||||
@ -29,6 +29,8 @@ import com.mysema.query.types.Ops;
|
||||
import com.mysema.query.types.Path;
|
||||
|
||||
/**
|
||||
* Serializes Querydsl queries to Lucene queries.
|
||||
*
|
||||
* @author vema
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.search;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -26,8 +31,11 @@ import com.mysema.query.SearchResults;
|
||||
import com.mysema.query.types.path.PString;
|
||||
import com.mysema.query.types.path.PathBuilder;
|
||||
|
||||
/*
|
||||
* TODO Refactor SimpleTest and LuceneQuery into same test class, lot of the setUp stuff is similar?
|
||||
/**
|
||||
* Tests for LuceneQuery
|
||||
*
|
||||
* @author vema
|
||||
*
|
||||
*/
|
||||
public class LuceneQueryTest {
|
||||
private LuceneQuery query;
|
||||
|
||||
@ -30,7 +30,12 @@ import com.mysema.query.types.Expr;
|
||||
import com.mysema.query.types.path.PString;
|
||||
import com.mysema.query.types.path.PathBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for LuceneSerializer
|
||||
*
|
||||
* @author vema
|
||||
*
|
||||
*/
|
||||
public class LuceneSerializerTest {
|
||||
private LuceneSerializer serializer;
|
||||
private PathBuilder<Object> entityPath;
|
||||
@ -281,91 +286,4 @@ public class LuceneSerializerTest {
|
||||
fail("Not yet implemented!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specs(){
|
||||
|
||||
PathBuilder<Object> entityPath = new PathBuilder<Object>(Object.class, "obj");
|
||||
PString stringPath = entityPath.getString("prop");
|
||||
|
||||
// LuceneQuery<Object> query = new LuceneQuery<Object>(session, entityPath);
|
||||
|
||||
// LuceneSerializer serializer = new LuceneSerializer();
|
||||
|
||||
// Terms & Phrases
|
||||
// "test" or "hello dolly"
|
||||
// c.Match("test") or c.Match("hello dolly")
|
||||
// assertEquals("obj.prop:test obj.prop:hello dolly", serializer.toQuery(stringPath.like("test").or(stringPath.like("hello dolly"))).toString());
|
||||
|
||||
// Fields
|
||||
// title:"The Right way" and text:go
|
||||
// c.Title == "The Right way" and c.Text == "go"
|
||||
// assertEquals("obj.prop:The Right Way AND obj.prop:go", serializer.toQuery(stringPath.eq("The Right Way").and(stringPath.eq("go"))).toString());
|
||||
|
||||
// WildCard
|
||||
// amb?r
|
||||
// c.ContactName.Match("amb?r")
|
||||
stringPath.like("amb?r");
|
||||
|
||||
// Prefix
|
||||
// amber*
|
||||
// c.ContactName.StartsWith("amber")
|
||||
stringPath.startsWith("amber");
|
||||
|
||||
// Fuzzy
|
||||
// roam~ or roam~0.8
|
||||
// c.ContactName.Like("roam") or c.ContactName.Like("roam", 0.8)
|
||||
// TODO
|
||||
|
||||
// Proximity
|
||||
// "jakarta apache"~10
|
||||
// c.ContactName.Like("jakarta apache", 10)
|
||||
// TODO
|
||||
|
||||
// Inclusive Range
|
||||
// mod_date:[20020101 TO 20030101]
|
||||
// c.ModifiedDate.Includes("20020101", "20030101")
|
||||
// stringPath.between("20020101", "20030101");
|
||||
// TODO
|
||||
|
||||
// Exclusive Range
|
||||
// title:{Aida TO Carmen}
|
||||
// c.Title.Between("Aida", "Carmen")
|
||||
stringPath.between("Aida", "Carmen");
|
||||
|
||||
// Boosting
|
||||
// jakarta^4 apache
|
||||
// c.Title.Match("jakarta".Boost(4), apache)
|
||||
// TODO
|
||||
|
||||
// Boolean Or
|
||||
// "jakarta apache" OR jakarta
|
||||
// where c.Match("jakarta apache") || c.Match("jakarta")
|
||||
stringPath.like("jakarta apache").or(stringPath.like("jakarta"));
|
||||
|
||||
// Boolean And
|
||||
// "jakarta apache" AND "Apache Lucene"
|
||||
// where c.Match("jakarta apache") && c.Match("Apache Lucene")
|
||||
stringPath.like("jakarta apache").and(stringPath.like("Apache Lucene"));
|
||||
|
||||
// Boolean Not
|
||||
// "jakarta apache" NOT "Apache Lucene"
|
||||
// where c.Match("jakarta apache") && !c.Match("Apache Lucene")
|
||||
stringPath.like("jakarta apache").and(stringPath.like("Apache Lucene").not());
|
||||
|
||||
// Required
|
||||
// +jakarta lucene
|
||||
// c.Title.Match("jakarta".Require(), "lucene")
|
||||
// TODO
|
||||
|
||||
// Grouping
|
||||
// (jakarta OR apache) AND website
|
||||
// where (c.Title == "jakarta" || c.Title == "apache") && (c.Title == "website")
|
||||
stringPath.eq("jakarta").or(stringPath.eq("apache")).and(stringPath.eq("website"));
|
||||
|
||||
// Native syntax
|
||||
// ie. title:{+return +"pink panther")
|
||||
// c.Search("title:(return +\"pink panther\"")
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user