use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class QomTest method before.
@Before
public void before() throws RepositoryException {
Session session = getAdminSession();
vf = session.getValueFactory();
QueryManager qm = session.getWorkspace().getQueryManager();
f = qm.getQOMFactory();
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class QueryFulltextTest method testScoreWithOr.
public void testScoreWithOr() throws Exception {
Session session = superuser;
QueryManager qm = session.getWorkspace().getQueryManager();
Node n1 = testRootNode.addNode("node1");
n1.setProperty("text", "hello");
n1.setProperty("id", "1");
session.save();
String xpath = "/jcr:root//*[jcr:contains(@text, 'hello') or @id = '1']";
Query q = qm.createQuery(xpath, "xpath");
String result = getResult(q.execute(), "jcr:path");
assertEquals("/testroot/node1", result);
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class QueryFulltextTest method testSurrogateFulltext.
public void testSurrogateFulltext() throws Exception {
String surrogateString = "壱\n" + "複数の文字\n" + "カナポ\n" + "ハンカクポ\n" + "表十ソ\n" + "𠮟\n" + "Mixあポピ表𠮟" + "";
String[] searchStrs = new String[] { "𠮟", "Mix" };
Session session = superuser;
QueryManager qm = session.getWorkspace().getQueryManager();
Node n1 = testRootNode.addNode("node");
n1.setProperty("text", surrogateString);
session.save();
for (String searchTerm : searchStrs) {
String sql2 = "select [jcr:path] as [path] from [nt:base] " + "where contains([text], '" + searchTerm + "') order by [jcr:path]";
Query q = qm.createQuery(sql2, Query.JCR_SQL2);
log.println("Testing" + searchTerm);
assertEquals("Lookup failed for " + searchTerm, "/testroot/node", getResult(q.execute(), "path"));
}
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class FacetTest method testFacetRetrievalNumberOfFacetsConfiguredLowerThanDefault.
public void testFacetRetrievalNumberOfFacetsConfiguredLowerThanDefault() throws RepositoryException {
Node facetsConfig = superuser.getNode(FACET_CONFING_NODE_PATH);
facetsConfig.setProperty(LuceneIndexConstants.PROP_FACETS_TOP_CHILDREN, 7);
markIndexForReindex();
superuser.save();
superuser.refresh(true);
Session session = superuser;
Node n1 = testRootNode.addNode("node1");
String pn = "jcr:title";
n1.setProperty(pn, "hello 1");
Node n2 = testRootNode.addNode("node2");
n2.setProperty(pn, "hallo 2");
Node n3 = testRootNode.addNode("node3");
n3.setProperty(pn, "hallo 3");
Node n4 = testRootNode.addNode("node4");
n4.setProperty(pn, "hallo 4");
Node n5 = testRootNode.addNode("node5");
n5.setProperty(pn, "hallo 5");
Node n6 = testRootNode.addNode("node6");
n6.setProperty(pn, "hallo 6");
Node n7 = testRootNode.addNode("node7");
n7.setProperty(pn, "hallo 7");
Node n8 = testRootNode.addNode("node8");
n8.setProperty(pn, "hallo 8");
Node n9 = testRootNode.addNode("node9");
n9.setProperty(pn, "hallo 9");
Node n10 = testRootNode.addNode("node10");
n10.setProperty(pn, "hallo 10");
Node n11 = testRootNode.addNode("node11");
n11.setProperty(pn, "hallo 11");
Node n12 = testRootNode.addNode("node12");
n12.setProperty(pn, "hallo 12");
session.save();
QueryManager qm = session.getWorkspace().getQueryManager();
String sql2 = "select [jcr:path], [rep:facet(" + pn + ")] from [nt:base] " + "where contains([" + pn + "], 'hallo') order by [jcr:path]";
Query q = qm.createQuery(sql2, Query.JCR_SQL2);
QueryResult result = q.execute();
FacetResult facetResult = new FacetResult(result);
assertNotNull(facetResult);
assertNotNull(facetResult.getDimensions());
assertEquals(1, facetResult.getDimensions().size());
assertTrue(facetResult.getDimensions().contains(pn));
List<FacetResult.Facet> facets = facetResult.getFacets(pn);
assertNotNull(facets);
assertEquals(7, facets.size());
}
use of javax.jcr.query.QueryManager in project jackrabbit-oak by apache.
the class LuceneIndexSuggestionTest method suggestNodeName.
//OAK-3825
@Test
public void suggestNodeName() throws Exception {
final String nodeType = "nt:unstructured";
createSuggestIndex("lucene-suggest", nodeType, LuceneIndexConstants.PROPDEF_PROP_NODE_NAME);
root.addNode("indexedNode", nodeType);
session.save();
String suggQuery = createSuggestQuery(nodeType, "indexedn");
QueryManager queryManager = session.getWorkspace().getQueryManager();
QueryResult result = queryManager.createQuery(suggQuery, Query.JCR_SQL2).execute();
RowIterator rows = result.getRows();
String value = null;
while (rows.hasNext()) {
Row firstRow = rows.nextRow();
value = firstRow.getValue("suggestion").getString();
break;
}
assertEquals("Node name should be suggested", "indexedNode", value);
}
Aggregations