use of javax.jcr.query.Query in project jackrabbit by apache.
the class FulltextQueryTest method testContainsStarSQL.
public void testContainsStarSQL() throws RepositoryException {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "tEst text" });
n.setProperty("mytext", new String[] { "The quick brown Fox jumps over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "The quick brown Fox jumps over the lazy dog." });
n.setProperty("mytext", new String[] { "text text" });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE jcr:path LIKE '" + testRoot + "/%" + "' AND CONTAINS(., 'fox jumps')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
checkResult(q.execute(), 2);
}
use of javax.jcr.query.Query in project jackrabbit by apache.
the class FulltextQueryTest method testFulltextPhraseSQL.
public void testFulltextPhraseSQL() throws Exception {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "test text" });
n.setProperty("mytext", new String[] { "the quick brown jumps fox over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "other text" });
n.setProperty("mytext", new String[] { "the quick brown fox jumps over the lazy dog." });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%" + "' AND CONTAINS(., 'text \"fox jumps\"')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 1);
}
use of javax.jcr.query.Query in project jackrabbit by apache.
the class FulltextQueryTest method testContainsStarXPath.
public void testContainsStarXPath() throws RepositoryException {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "tEst text" });
n.setProperty("mytext", new String[] { "The quick brown Fox jumps over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "The quick brown Fox jumps over the lazy dog." });
n.setProperty("mytext", new String[] { "text text" });
testRootNode.save();
String sql = "/jcr:root" + testRoot + "/element(*, nt:unstructured)" + "[jcr:contains(., 'quick fox')]";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.XPATH);
checkResult(q.execute(), 2);
}
use of javax.jcr.query.Query in project jackrabbit by apache.
the class FulltextQueryTest method testFulltextIntercapSQL.
public void testFulltextIntercapSQL() throws Exception {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "tEst text" });
n.setProperty("mytext", new String[] { "The quick brown Fox jumps over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "Other text" });
n.setProperty("mytext", new String[] { "the quick brown FOX jumPs over the lazy dog." });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%" + "' AND CONTAINS(., '''fox juMps'' Test OR otheR')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 2);
}
use of javax.jcr.query.Query in project jackrabbit by apache.
the class FulltextQueryTest method testContainsPropScopeSQL.
public void testContainsPropScopeSQL() throws RepositoryException {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "tEst text" });
n.setProperty("mytext", new String[] { "The quick brown Fox jumps over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "The quick brown Fox jumps over the lazy dog." });
n.setProperty("mytext", new String[] { "text text" });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE jcr:path LIKE '" + testRoot + "/%" + "' AND CONTAINS(title, 'fox jumps')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
checkResult(q.execute(), 1);
}
Aggregations