Search in sources :

Example 1 with LuceneSerializer

use of com.querydsl.lucene5.LuceneSerializer in project querydsl by querydsl.

the class PhraseElementTest method test.

@Test
public void test() {
    StringPath title = Expressions.stringPath("title");
    LuceneSerializer serializer = new LuceneSerializer(false, false);
    QueryMetadata metadata = new DefaultQueryMetadata();
    assertEquals("title:Hello World", serializer.toQuery(title.eq("Hello World"), metadata).toString());
    assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) StringPath(com.querydsl.core.types.dsl.StringPath) PhraseElement(com.querydsl.lucene5.PhraseElement) LuceneSerializer(com.querydsl.lucene5.LuceneSerializer) Test(org.junit.Test)

Example 2 with LuceneSerializer

use of com.querydsl.lucene5.LuceneSerializer in project querydsl by querydsl.

the class TermElementTest method test.

@Test
public void test() {
    StringPath title = Expressions.stringPath("title");
    LuceneSerializer serializer = new LuceneSerializer(false, true);
    QueryMetadata metadata = new DefaultQueryMetadata();
    assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq("Hello World"), metadata).toString());
    assertEquals("title:Hello World", serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) TermElement(com.querydsl.lucene5.TermElement) StringPath(com.querydsl.core.types.dsl.StringPath) LuceneSerializer(com.querydsl.lucene5.LuceneSerializer) Test(org.junit.Test)

Aggregations

DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)2 QueryMetadata (com.querydsl.core.QueryMetadata)2 StringPath (com.querydsl.core.types.dsl.StringPath)2 LuceneSerializer (com.querydsl.lucene5.LuceneSerializer)2 Test (org.junit.Test)2 PhraseElement (com.querydsl.lucene5.PhraseElement)1 TermElement (com.querydsl.lucene5.TermElement)1