Search in sources :

Example 1 with FullTextSearch

use of javax.jcr.query.qom.FullTextSearch in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testFullTextSearchAllProperties.

/**
     * 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());
}
Also used : FullTextSearch(javax.jcr.query.qom.FullTextSearch)

Example 2 with FullTextSearch

use of javax.jcr.query.qom.FullTextSearch in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testFullTextSearchWithBindVariableValue.

/**
     * 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());
}
Also used : BindVariableValue(javax.jcr.query.qom.BindVariableValue) StaticOperand(javax.jcr.query.qom.StaticOperand) FullTextSearch(javax.jcr.query.qom.FullTextSearch)

Example 3 with FullTextSearch

use of javax.jcr.query.qom.FullTextSearch in project jackrabbit-oak by apache.

the class QomTest method fullTextSearch.

@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());
}
Also used : Literal(javax.jcr.query.qom.Literal) FullTextSearch(javax.jcr.query.qom.FullTextSearch) Test(org.junit.Test) AbstractRepositoryTest(org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)

Example 4 with FullTextSearch

use of javax.jcr.query.qom.FullTextSearch in project jackrabbit by apache.

the class LuceneQueryFactory method create.

protected Query create(Constraint constraint, Map<String, NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException {
    if (constraint instanceof And) {
        return getAndQuery((And) constraint, selectorMap, searcher);
    } else if (constraint instanceof Or) {
        return getOrQuery((Or) constraint, selectorMap, searcher);
    } else if (constraint instanceof Not) {
        return getNotQuery((Not) constraint, selectorMap, searcher);
    } else if (constraint instanceof PropertyExistence) {
        return getPropertyExistenceQuery((PropertyExistence) constraint);
    } else if (constraint instanceof Comparison) {
        Comparison c = (Comparison) constraint;
        Transform left = new Transform(c.getOperand1());
        return getComparisonQuery(left.operand, left.transform, c.getOperator(), c.getOperand2(), selectorMap);
    } else if (constraint instanceof FullTextSearch) {
        return getFullTextSearchQuery((FullTextSearch) constraint);
    } else if (constraint instanceof SameNode) {
        SameNode sn = (SameNode) constraint;
        return getNodeIdQuery(UUID, sn.getPath());
    } else if (constraint instanceof ChildNode) {
        ChildNode cn = (ChildNode) constraint;
        return getNodeIdQuery(PARENT, cn.getParentPath());
    } else if (constraint instanceof DescendantNode) {
        DescendantNode dn = (DescendantNode) constraint;
        return getDescendantNodeQuery(dn, searcher);
    } else {
        throw new UnsupportedRepositoryOperationException("Unknown constraint type: " + constraint);
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Not(javax.jcr.query.qom.Not) Or(javax.jcr.query.qom.Or) Comparison(javax.jcr.query.qom.Comparison) And(javax.jcr.query.qom.And) DescendantNode(javax.jcr.query.qom.DescendantNode) FullTextSearch(javax.jcr.query.qom.FullTextSearch) SameNode(javax.jcr.query.qom.SameNode) PropertyExistence(javax.jcr.query.qom.PropertyExistence) ChildNode(javax.jcr.query.qom.ChildNode)

Example 5 with FullTextSearch

use of javax.jcr.query.qom.FullTextSearch in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testFullTextSearch.

/**
     * 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());
}
Also used : StaticOperand(javax.jcr.query.qom.StaticOperand) Literal(javax.jcr.query.qom.Literal) FullTextSearch(javax.jcr.query.qom.FullTextSearch)

Aggregations

FullTextSearch (javax.jcr.query.qom.FullTextSearch)5 Literal (javax.jcr.query.qom.Literal)2 StaticOperand (javax.jcr.query.qom.StaticOperand)2 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 And (javax.jcr.query.qom.And)1 BindVariableValue (javax.jcr.query.qom.BindVariableValue)1 ChildNode (javax.jcr.query.qom.ChildNode)1 Comparison (javax.jcr.query.qom.Comparison)1 DescendantNode (javax.jcr.query.qom.DescendantNode)1 Not (javax.jcr.query.qom.Not)1 Or (javax.jcr.query.qom.Or)1 PropertyExistence (javax.jcr.query.qom.PropertyExistence)1 SameNode (javax.jcr.query.qom.SameNode)1 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)1 Test (org.junit.Test)1