Search in sources :

Example 1 with QueryParser

use of com.zimbra.cs.index.query.parser.QueryParser in project zm-mailbox by Zimbra.

the class QueryParserTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    prov.createAccount("test@zimbra.com", "secret", new HashMap<String, Object>());
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    parser = new QueryParser(mbox, ZimbraAnalyzer.getInstance());
}
Also used : QueryParser(com.zimbra.cs.index.query.parser.QueryParser) Mailbox(com.zimbra.cs.mailbox.Mailbox) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) BeforeClass(org.junit.BeforeClass)

Example 2 with QueryParser

use of com.zimbra.cs.index.query.parser.QueryParser in project zm-mailbox by Zimbra.

the class QueryParserTest method contactContent.

@Test
public void contactContent() throws Exception {
    QueryParser parser = new QueryParser(null, ZimbraAnalyzer.getInstance());
    parser.setTypes(EnumSet.of(MailItem.Type.CONTACT));
    String src = "zimbra";
    Assert.assertEquals("(Q(CONTACT:zimbra) || Q(l.content:zimbra))", Query.toString(parser.parse(src)));
    // stop word
    src = "in";
    Assert.assertEquals("(Q(CONTACT:in) || Q(l.content:))", Query.toString(parser.parse(src)));
}
Also used : QueryParser(com.zimbra.cs.index.query.parser.QueryParser) Test(org.junit.Test)

Example 3 with QueryParser

use of com.zimbra.cs.index.query.parser.QueryParser in project zm-mailbox by Zimbra.

the class QueryParserTest method contact.

@Test
public void contact() throws Exception {
    QueryParser parser = new QueryParser(null, ZimbraAnalyzer.getInstance());
    String src = "contact:\"Conf -\"";
    Assert.assertEquals("Q(CONTACT:conf,-)", Query.toString(parser.parse(src)));
    src = "contact:\"Conf - Prom\"";
    Assert.assertEquals("Q(CONTACT:conf,-,prom)", Query.toString(parser.parse(src)));
    src = "contact:\"Conf - Promontory E\"";
    Assert.assertEquals("Q(CONTACT:conf,-,promontory,e)", Query.toString(parser.parse(src)));
    src = "contact:\"Conf - Promontory E*****\"";
    Assert.assertEquals("Q(CONTACT:conf,-,promontory,e)", Query.toString(parser.parse(src)));
    src = "contact:\"Conf - Prom* E*\"";
    Assert.assertEquals("Q(CONTACT:conf,-,prom,e)", Query.toString(parser.parse(src)));
}
Also used : QueryParser(com.zimbra.cs.index.query.parser.QueryParser) Test(org.junit.Test)

Example 4 with QueryParser

use of com.zimbra.cs.index.query.parser.QueryParser in project zm-mailbox by Zimbra.

the class QueryParserTest method quoted.

@Test
public void quoted() throws Exception {
    QueryParser parser = new QueryParser(null, ZimbraAnalyzer.getInstance());
    parser.setTypes(EnumSet.of(MailItem.Type.CONTACT));
    Assert.assertEquals("(Q(CONTACT:zimbra,quoted,test) || Q(l.content:zimbra,quoted,test))", Query.toString(parser.parse("\"Zimbra \\\"quoted\\\" test\"")));
}
Also used : QueryParser(com.zimbra.cs.index.query.parser.QueryParser) Test(org.junit.Test)

Example 5 with QueryParser

use of com.zimbra.cs.index.query.parser.QueryParser in project zm-mailbox by Zimbra.

the class QueryParserTest method quick.

@Test
public void quick() throws Exception {
    QueryParser parser = new QueryParser(null, ZimbraAnalyzer.getInstance());
    parser.setQuick(true);
    Assert.assertEquals("Q(l.content:all,hands,meeting[*])", Query.toString(parser.parse("all hands meeting")));
    Assert.assertEquals("Q(l.content:all,hands,meeting[*])", Query.toString(parser.parse("all hands meeting*")));
}
Also used : QueryParser(com.zimbra.cs.index.query.parser.QueryParser) Test(org.junit.Test)

Aggregations

QueryParser (com.zimbra.cs.index.query.parser.QueryParser)5 Test (org.junit.Test)4 MockProvisioning (com.zimbra.cs.account.MockProvisioning)1 Provisioning (com.zimbra.cs.account.Provisioning)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 BeforeClass (org.junit.BeforeClass)1