org.modeshape.jcr.query.lucene

## Class LuceneQueryFactory

- java.lang.Object
- - org.modeshape.jcr.query.lucene.LuceneQueryFactory

- Direct Known Subclasses:
    BasicLuceneQueryFactory

      @NotThreadSafe
      public abstract class LuceneQueryFactory
      extends Object

  The factory that creates a Lucene `Query` object from a Query Object Model `Constraint` object.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected QueryContext` | `context`
    `protected ValueFactories` | `factories`
    `protected NameFactory` | `nameFactory`
    `protected PathFactory` | `pathFactory`
    `protected org.hibernate.search.SearchFactory` | `searchFactory`
    `protected ValueFactory<String>` | `stringFactory`
    `protected org.apache.lucene.util.Version` | `version`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `LuceneQueryFactory(QueryContext context, org.hibernate.search.SearchFactory searchFactory, org.apache.lucene.util.Version version)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `createOperand(SelectorName selectorName, StaticOperand operand, CaseOperations.CaseOperation caseOperation)`
    `org.apache.lucene.search.Query` | `createQuery(SelectorName selectorName, Constraint constraint)` Create a Lucene `Query` that represents the supplied Query Object Model `Constraint`.
    `org.apache.lucene.search.Query` | `createQuery(SelectorName selectorName, DynamicOperand left, Operator operator, StaticOperand right)`
    `protected org.apache.lucene.search.Query` | `createQuery(SelectorName selectorName, DynamicOperand left, Operator operator, StaticOperand right, CaseOperations.CaseOperation caseOperation)` Create a comparison query
    `org.apache.lucene.search.Query` | `createQuery(SelectorName selectorName, DynamicOperand left, StaticOperand lower, StaticOperand upper, boolean includesLower, boolean includesUpper, CaseOperations.CaseOperation caseOperation)`
    `org.apache.lucene.search.Query` | `createQuery(SelectorName selectorName, PropertyExistence existence)`
    `org.apache.lucene.search.Query` | `createQuery(SelectorName selectorName, String fieldName, FullTextSearch.Term term)`
    `protected String` | `fieldNameFor(String name)`
    `protected abstract org.apache.lucene.search.Query` | `findAllNodesAtOrBelow(Path ancestorPath)` Return a query that will find all documents representing nodes at or below the supplied path.
    `protected abstract org.apache.lucene.search.Query` | `findAllNodesBelow(Path ancestorPath)` Return a query that will find all documents representing nodes below the supplied path.
    `protected abstract org.apache.lucene.search.Query` | `findChildNodes(Path parentPath)` Return a query that can be used to find all of the documents that represent nodes that are children of the node at the supplied path.
    `protected abstract org.apache.lucene.search.Query` | `findNodeAt(Path path)` Create a query that can be used to find the one document (or node) that exists at the exact path supplied.
    `protected abstract org.apache.lucene.search.Query` | `findNodesLike(SelectorName selectorName, String fieldName, String likeExpression, CaseOperations.CaseOperation caseOperation)` Construct a `Query` implementation that scores documents with a string field value that is LIKE the supplied constraint value, where the LIKE expression contains the SQL wildcard characters '%' and '_' or the regular expression wildcard characters '*' and '?'.
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, Length propertyLength, Operator operator, Object value)` Create a query that finds documents with fields whose lengths fit the supplied operator/value criteria.
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodeDepth depthConstraint, Operator operator, Object value)`
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodeLocalName nodeName, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)`
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodeName nodeName, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)`
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodePath nodePath, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)`
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, PropertyValue propertyValue, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)` Create a query that finds documents with fields whose values fit the supplied operator/value criteria.
    `protected abstract org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, ReferenceValue referenceValue, Operator operator, Object value)` Create a query that finds documents with fields that are references that fit the supplied operator/value criteria.
    `protected abstract org.apache.lucene.search.Query` | `findNodesWithNumericRange(SelectorName selectorName, NodeDepth depth, Object lowerValue, Object upperValue, boolean includesLower, boolean includesUpper)` Create a query that finds documents with fields with depths that are in the supplied range.
    `protected abstract org.apache.lucene.search.Query` | `findNodesWithNumericRange(SelectorName selectorName, PropertyValue propertyValue, Object lowerValue, Object upperValue, boolean includesLower, boolean includesUpper)` Create a query that finds documents with fields with values that are in the supplied range.
    `protected abstract String` | `fullTextFieldName(String propertyName)` Create the field name that will be used to store the full-text searchable property values.
    `protected abstract org.apache.lucene.analysis.Analyzer` | `getFullTextSearchAnalyzer()`
    `protected Schemata.Column` | `getMetadataFor(SelectorName selectorName, String propertyName)`
    `protected org.apache.lucene.search.Query` | `not(org.apache.lucene.search.Query notted)`
    `protected Schemata` | `schemata()`
    `protected String` | `stringValueFrom(Object value)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### context

          protected final QueryContext context

    - #### searchFactory

          protected final org.hibernate.search.SearchFactory searchFactory

    - #### factories

          protected final ValueFactories factories

    - #### pathFactory

          protected final PathFactory pathFactory

    - #### nameFactory

          protected final NameFactory nameFactory

    - #### stringFactory

          protected final ValueFactory<String> stringFactory

    - #### version

          protected final org.apache.lucene.util.Version version

  - ### Constructor Detail

    - #### LuceneQueryFactory

          protected LuceneQueryFactory(QueryContext context,
                            org.hibernate.search.SearchFactory searchFactory,
                            org.apache.lucene.util.Version version)

  - ### Method Detail

    - #### createQuery

          public org.apache.lucene.search.Query createQuery(SelectorName selectorName,
                                                   Constraint constraint)
                                                     throws IOException

      Create a Lucene `Query` that represents the supplied Query Object Model `Constraint`.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `constraint` - the QOM constraint; never null
      Returns:
        the corresponding Query object; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### createQuery

          public org.apache.lucene.search.Query createQuery(SelectorName selectorName,
                                                   DynamicOperand left,
                                                   Operator operator,
                                                   StaticOperand right)
                                                     throws IOException

      Throws:
        `IOException`

    - #### createQuery

          protected org.apache.lucene.search.Query createQuery(SelectorName selectorName,
                                                   DynamicOperand left,
                                                   Operator operator,
                                                   StaticOperand right,
                                                   CaseOperations.CaseOperation caseOperation)
                                                        throws IOException

      Create a comparison query
      Parameters:
        `selectorName` -
        `left` -
        `operator` -
        `right` -
        `caseOperation` - the case operation if known, or null if not known. Normally a non-null value would be required, but in the case of chained functions such as UPPER(LOWER(...)) we only want to use the first one, so passing null allows us to easily use the outer one
      Returns:
        the query
      Throws:
        `IOException`

    - #### createOperand

          public Object createOperand(SelectorName selectorName,
                             StaticOperand operand,
                             CaseOperations.CaseOperation caseOperation)

    - #### createQuery

          public org.apache.lucene.search.Query createQuery(SelectorName selectorName,
                                                   DynamicOperand left,
                                                   StaticOperand lower,
                                                   StaticOperand upper,
                                                   boolean includesLower,
                                                   boolean includesUpper,
                                                   CaseOperations.CaseOperation caseOperation)
                                                     throws IOException

      Throws:
        `IOException`

    - #### stringValueFrom

          protected String stringValueFrom(Object value)

    - #### createQuery

          public org.apache.lucene.search.Query createQuery(SelectorName selectorName,
                                                   PropertyExistence existence)

    - #### createQuery

          public org.apache.lucene.search.Query createQuery(SelectorName selectorName,
                                                   String fieldName,
                                                   FullTextSearch.Term term)
                                                     throws IOException

      Throws:
        `IOException`

    - #### not

          protected org.apache.lucene.search.Query not(org.apache.lucene.search.Query notted)

    - #### fieldNameFor

          protected String fieldNameFor(String name)

    - #### fullTextFieldName

          protected abstract String fullTextFieldName(String propertyName)

      Create the field name that will be used to store the full-text searchable property values.
      Parameters:
        `propertyName` - the name of the property; may not null
      Returns:
        the field name for the full-text searchable property values; never null

    - #### getFullTextSearchAnalyzer

          protected abstract org.apache.lucene.analysis.Analyzer getFullTextSearchAnalyzer()

    - #### findAllNodesBelow

          protected abstract org.apache.lucene.search.Query findAllNodesBelow(Path ancestorPath)
                                                                       throws IOException

      Return a query that will find all documents representing nodes below the supplied path.
      Parameters:
        `ancestorPath` - the path of the ancestor node; never null
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findAllNodesAtOrBelow

          protected abstract org.apache.lucene.search.Query findAllNodesAtOrBelow(Path ancestorPath)
                                                                           throws IOException

      Return a query that will find all documents representing nodes at or below the supplied path.
      Parameters:
        `ancestorPath` - the path of the ancestor node; never null
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findChildNodes

          protected abstract org.apache.lucene.search.Query findChildNodes(Path parentPath)
                                                                    throws IOException

      Return a query that can be used to find all of the documents that represent nodes that are children of the node at the supplied path.
      Parameters:
        `parentPath` - the path of the parent node.
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodeAt

          protected abstract org.apache.lucene.search.Query findNodeAt(Path path)
                                                                throws IOException

      Create a query that can be used to find the one document (or node) that exists at the exact path supplied.
      Parameters:
        `path` - the path of the node
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodesLike

          protected abstract org.apache.lucene.search.Query findNodesLike(SelectorName selectorName,
                                                     String fieldName,
                                                     String likeExpression,
                                                     CaseOperations.CaseOperation caseOperation)

      Construct a `Query` implementation that scores documents with a string field value that is LIKE the supplied constraint value, where the LIKE expression contains the SQL wildcard characters '%' and '_' or the regular expression wildcard characters '*' and '?'.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `fieldName` - the name of the document field to search
        `likeExpression` - the JCR like expression
        `caseOperation` - the operation that should be performed on the indexed string before being used; may not be null
      Returns:
        the query; never null

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     Length propertyLength,
                                                     Operator operator,
                                                     Object value)
                                                                   throws IOException

      Create a query that finds documents with fields whose lengths fit the supplied operator/value criteria.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `propertyLength` - the property specification
        `operator` - the comparison operator
        `value` - the length value
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     PropertyValue propertyValue,
                                                     Operator operator,
                                                     Object value,
                                                     CaseOperations.CaseOperation caseOperation)
                                                                   throws IOException

      Create a query that finds documents with fields whose values fit the supplied operator/value criteria.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `propertyValue` - the property specification
        `operator` - the comparison operator
        `value` - the value
        `caseOperation` - the operation that should be used against the string values in the indexes before applying the criteria, or null if the operation is not known
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     ReferenceValue referenceValue,
                                                     Operator operator,
                                                     Object value)
                                                                   throws IOException

      Create a query that finds documents with fields that are references that fit the supplied operator/value criteria.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `referenceValue` - the property specification
        `operator` - the comparison operator
        `value` - the reference value
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodesWithNumericRange

          protected abstract org.apache.lucene.search.Query findNodesWithNumericRange(SelectorName selectorName,
                                                                 PropertyValue propertyValue,
                                                                 Object lowerValue,
                                                                 Object upperValue,
                                                                 boolean includesLower,
                                                                 boolean includesUpper)
                                                                               throws IOException

      Create a query that finds documents with fields with values that are in the supplied range.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `propertyValue` - the property specification
        `lowerValue` - the lower value
        `upperValue` - the upper value
        `includesLower` - true if the range should include the lower value, or false if the lower value should be excluded
        `includesUpper` - true if the range should include the upper value, or false if the upper value should be excluded
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodesWithNumericRange

          protected abstract org.apache.lucene.search.Query findNodesWithNumericRange(SelectorName selectorName,
                                                                 NodeDepth depth,
                                                                 Object lowerValue,
                                                                 Object upperValue,
                                                                 boolean includesLower,
                                                                 boolean includesUpper)
                                                                               throws IOException

      Create a query that finds documents with fields with depths that are in the supplied range.
      Parameters:
        `selectorName` - the name of the selector (or node type) being queried; may not be null
        `depth` - the property specification
        `lowerValue` - the lower value
        `upperValue` - the upper value
        `includesLower` - true if the range should include the lower value, or false if the lower value should be excluded
        `includesUpper` - true if the range should include the upper value, or false if the upper value should be excluded
      Returns:
        the query; never null
      Throws:
        `IOException` - if there is an error creating the query

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     NodePath nodePath,
                                                     Operator operator,
                                                     Object value,
                                                     CaseOperations.CaseOperation caseOperation)
                                                                   throws IOException

      Throws:
        `IOException`

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     NodeName nodeName,
                                                     Operator operator,
                                                     Object value,
                                                     CaseOperations.CaseOperation caseOperation)
                                                                   throws IOException

      Throws:
        `IOException`

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     NodeLocalName nodeName,
                                                     Operator operator,
                                                     Object value,
                                                     CaseOperations.CaseOperation caseOperation)
                                                                   throws IOException

      Throws:
        `IOException`

    - #### findNodesWith

          protected abstract org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     NodeDepth depthConstraint,
                                                     Operator operator,
                                                     Object value)
                                                                   throws IOException

      Throws:
        `IOException`

    - #### schemata

          protected Schemata schemata()

    - #### getMetadataFor

          protected Schemata.Column getMetadataFor(SelectorName selectorName,
                                       String propertyName)

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.