public void testOrdering() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))), qf.descendantNode("s", testRootNode.getPath()) ), new Ordering[]{qf.ascending(qf.fullTextSearchScore("s"))}, null ); forQOMandSQL2(qom, new Callable() { public Object call(Query query) throws RepositoryException { RowIterator rows = query.execute().getRows(); double previousScore = Double.NaN; while (rows.hasNext()) { double score = rows.nextRow().getScore("s"); if (!Double.isNaN(previousScore)) { assertTrue("wrong order", previousScore <= score); } previousScore = score; } return null; } }); }
@Test public void fullTextSearch() throws RepositoryException { Literal l = f.literal(vf.createValue(1)); FullTextSearch x = f.fullTextSearch("selectorName", "propertyName", l); assertEquals("selectorName", x.getSelectorName()); assertEquals("propertyName", x.getPropertyName()); assertEquals(l, x.getFullTextSearchExpression()); assertEquals("CONTAINS([selectorName].[propertyName], 1)", x.toString()); assertEquals("CONTAINS([p], null)", f.fullTextSearch(null, "p", null).toString()); assertEquals("CONTAINS([s].[p], null)", f.fullTextSearch("s", "p", null).toString()); assertEquals("CONTAINS([s].*, null)", f.fullTextSearch("s", null, null).toString()); assertEquals("CONTAINS(*, null)", f.fullTextSearch(null, null, null).toString()); }
/** * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)} */ public void testFullTextSearchAllProperties() throws RepositoryException { FullTextSearch ftSearch = qf.fullTextSearch( SELECTOR_NAME1, null, qf.literal(vf.createValue(FULLTEXT_SEARCH_EXPR))); assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName()); assertNull("Property name must be null", ftSearch.getPropertyName()); }
qf.and( qf.and( qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))), qf.comparison( qf.fullTextSearchScore("s"),
/** * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)} */ public void testFullTextSearch() throws RepositoryException { FullTextSearch ftSearch = qf.fullTextSearch( SELECTOR_NAME1, propertyName1, qf.literal(vf.createValue(FULLTEXT_SEARCH_EXPR))); assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName()); assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName()); StaticOperand op = ftSearch.getFullTextSearchExpression(); assertNotNull(op); assertTrue("not a Literal", op instanceof Literal); Literal literal = (Literal) op; assertEquals(FULLTEXT_SEARCH_EXPR, literal.getLiteralValue().getString()); }
if (readIf("*")) { read(","); c = factory.fullTextSearch( name, null, parseStaticOperand()); } else { name = readName(); read(","); c = factory.fullTextSearch( selector, name, parseStaticOperand()); c = factory.fullTextSearch( getOnlySelectorName(name), name, parseStaticOperand());
/** * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)} */ public void testFullTextSearchWithBindVariableValue() throws RepositoryException { FullTextSearch ftSearch = qf.fullTextSearch( SELECTOR_NAME1, propertyName1, qf.bindVariable(VARIABLE_NAME)); assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName()); assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName()); StaticOperand op = ftSearch.getFullTextSearchExpression(); assertNotNull(op); assertTrue("not a BindVariableValue", op instanceof BindVariableValue); BindVariableValue value = (BindVariableValue) op; assertEquals(VARIABLE_NAME, value.getBindVariableName()); }
if (readIf("*")) { read(","); c = factory.fullTextSearch( name, null, parseStaticOperand()); } else { name = readName(); read(","); c = factory.fullTextSearch( selector, name, parseStaticOperand()); c = factory.fullTextSearch( getOnlySelectorName(name), name, parseStaticOperand());
if (readIf("*")) { read(","); c = factory.fullTextSearch( name, null, parseStaticOperand()); } else { name = readName(); read(","); c = factory.fullTextSearch( selector, name, parseStaticOperand()); c = factory.fullTextSearch( getOnlySelectorName(name), name, parseStaticOperand());
@Test public void jcrNameConversion() throws RepositoryException { assertEquals("[nt:base]", f.column(null, NodeType.NT_BASE, null).toString()); assertEquals("[s1].[nt:base] = [s2].[nt:base]", f.equiJoinCondition("s1", NodeType.NT_BASE, "s2", NodeType.NT_BASE).toString()); assertEquals("CONTAINS([nt:base], null)", f.fullTextSearch(null, NodeType.NT_BASE, null).toString()); assertEquals("CAST('nt:base' AS NAME)", f.literal(vf.createValue(NodeType.NT_BASE, PropertyType.NAME)).toString()); assertEquals("[nt:base] IS NOT NULL", f.propertyExistence(null, NodeType.NT_BASE).toString()); assertEquals("[nt:base]", f.propertyValue(null, NodeType.NT_BASE).toString()); assertEquals("[nt:base]", f.selector(NodeType.NT_BASE, null).toString()); Source source1 = f.selector(NodeType.NT_BASE, "selector"); Column[] columns = new Column[] { f.column("selector", null, null) }; Constraint constraint2 = f.childNode("selector", "/"); QueryObjectModel qom = f.createQuery(source1, constraint2, null, columns); assertEquals("select [selector].* from " + "[nt:base] AS [selector] " + "where ISCHILDNODE([selector], [/])", qom.toString()); }