use of javax.jcr.query.QueryManager in project jackrabbit by apache.
the class MassiveRangeTest method testRangeQuery.
/**
* Executes a range query covering 2'000 different property values.
*/
public void testRangeQuery() throws RepositoryException {
int count = 0;
for (int i = 0; i < 20; i++) {
Node child = testRootNode.addNode("node" + i);
for (int j = 0; j < 100; j++) {
Node n = child.addNode("node" + j);
n.setProperty("foo", count++);
}
// save every 100 nodes
testRootNode.save();
}
QueryManager qm = superuser.getWorkspace().getQueryManager();
String stmt = testPath + "//*[@foo >= 0]";
QueryResult res = qm.createQuery(stmt, Query.XPATH).execute();
checkResult(res, 2000);
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class SpellcheckTest method testSpellcheckXPath.
public void testSpellcheckXPath() throws Exception {
Session session = superuser;
QueryManager qm = session.getWorkspace().getQueryManager();
Node n1 = testRootNode.addNode("node1");
n1.setProperty("jcr:title", "hello hello hello alt");
Node n2 = testRootNode.addNode("node2");
n2.setProperty("jcr:title", "hold");
session.save();
String xpath = "/jcr:root[rep:spellcheck('helo')]/(rep:spellcheck())";
Query q = qm.createQuery(xpath, Query.XPATH);
List<String> result = getResult(q.execute(), "rep:spellcheck()");
assertNotNull(result);
assertEquals(2, result.size());
assertEquals("[hello, hold]", result.toString());
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class SpellcheckTest method testSpellcheckMultipleWords.
public void testSpellcheckMultipleWords() throws Exception {
Session session = superuser;
QueryManager qm = session.getWorkspace().getQueryManager();
Node n1 = testRootNode.addNode("node1");
n1.setProperty("jcr:title", "it is always a good idea to go visiting ontario");
Node n2 = testRootNode.addNode("node2");
n2.setProperty("jcr:title", "ontario is a nice place to live in");
Node n3 = testRootNode.addNode("node3");
n2.setProperty("jcr:title", "I flied to ontario for voting for the major polls");
Node n4 = testRootNode.addNode("node4");
n2.setProperty("jcr:title", "I will go voting in ontario, I always voted since I've been allowed to");
session.save();
String xpath = "/jcr:root[rep:spellcheck('votin in ontari')]/(rep:spellcheck())";
Query q = qm.createQuery(xpath, Query.XPATH);
List<String> result = getResult(q.execute(), "rep:spellcheck()");
assertNotNull(result);
assertEquals(1, result.size());
assertEquals("voting in ontario", result.get(0));
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class SuggestTest method testSuggestSql.
public void testSuggestSql() throws Exception {
Session session = superuser;
QueryManager qm = session.getWorkspace().getQueryManager();
Node n1 = testRootNode.addNode("node1");
n1.setProperty("jcr:title", "in 2015 my fox is red, like mike's fox and john's fox");
Node n2 = testRootNode.addNode("node2");
n2.setProperty("jcr:title", "in 2015 a red fox is still a fox");
session.save();
String sql = "SELECT [rep:suggest()] FROM nt:base WHERE [jcr:path] = '/' AND SUGGEST('in 201')";
Query q = qm.createQuery(sql, Query.SQL);
List<String> result = getResult(q.execute(), "rep:suggest()");
assertNotNull(result);
assertEquals(2, result.size());
assertTrue(result.contains("in 2015 a red fox is still a fox"));
assertTrue(result.contains("in 2015 my fox is red, like mike's fox and john's fox"));
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class SuggestTest method testNoSuggestions.
public void testNoSuggestions() throws Exception {
Session session = superuser;
QueryManager qm = session.getWorkspace().getQueryManager();
Node n1 = testRootNode.addNode("node1");
n1.setProperty("jcr:title", "in 2015 my fox is red, like mike's fox and john's fox");
Node n2 = testRootNode.addNode("node2");
n2.setProperty("jcr:title", "in 2015 a red fox is still a fox");
session.save();
String sql = "SELECT [rep:suggest()] FROM nt:base WHERE [jcr:path] = '/' AND SUGGEST('blablabla')";
Query q = qm.createQuery(sql, Query.SQL);
List<String> result = getResult(q.execute(), "rep:suggest()");
assertNotNull(result);
assertEquals("There shouldn't be any suggestions", 0, result.size());
}
Aggregations