org.modeshape.jcr.query.lucene.basic

## Class BasicLuceneQueryFactory

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

-     public class BasicLuceneQueryFactory
      extends LuceneQueryFactory

  The `LuceneQueryFactory` customization that produces `Query` objects based upon the `BasicLuceneSchema`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `MAX_DEPTH`
    `protected static int` | `MAX_SNS_INDEX`
    `protected static int` | `MIN_DEPTH`
    `protected static int` | `MIN_SNS_INDEX`

    - ### Fields inherited from class org.modeshape.jcr.query.lucene.LuceneQueryFactory

      `context, factories, nameFactory, pathFactory, searchFactory, stringFactory, version`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicLuceneQueryFactory(QueryContext context, org.hibernate.search.SearchFactory searchFactory, org.apache.lucene.util.Version version)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected org.apache.lucene.search.Query` | `createSnsIndexQuery(String likeExpression)` Utility method to generate a query against the SNS indexes.
    `protected 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 org.apache.lucene.search.Query` | `findAllNodesBelow(Path ancestorPath)` Return a query that will find all documents representing nodes below the supplied path.
    `protected 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 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 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 org.apache.lucene.search.Query` | `findNodesLike(String fieldName, String likeExpression, CaseOperations.CaseOperation caseOperation)`
    `protected 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 org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodeDepth depthConstraint, Operator operator, Object value)`
    `protected org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodeLocalName nodeName, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)`
    `protected org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodeName nodeName, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)`
    `protected org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, NodePath nodePath, Operator operator, Object value, CaseOperations.CaseOperation caseOperation)`
    `protected 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 org.apache.lucene.search.Query` | `findNodesWith(SelectorName selectorName, PropertyValue propertyValue, Operator operator, Object value, CaseOperations.CaseOperation caseOperation, PropertyType valueType, Schemata.Column metadata)`
    `protected 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 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 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 org.apache.lucene.search.Query` | `findNodesWithNumericRange(SelectorName selectorName, String field, Object lowerValue, Object upperValue, boolean includesLower, boolean includesUpper)`
    `protected String` | `fullTextFieldName(String propertyName)` Create the field name that will be used to store the full-text searchable property values.
    `protected org.apache.lucene.analysis.Analyzer` | `getFullTextSearchAnalyzer()`
    `protected String` | `likeExpresionForWildcardPath(String path)`
    `protected String` | `pathAsString(Path path)`

    - ### Methods inherited from class org.modeshape.jcr.query.lucene.LuceneQueryFactory

      `createOperand, createQuery, createQuery, createQuery, createQuery, createQuery, createQuery, fieldNameFor, getMetadataFor, not, schemata, stringValueFrom`

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

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

- - ### Field Detail

    - #### MIN_DEPTH

          protected static final int MIN_DEPTH

      See Also:
        Constant Field Values

    - #### MAX_DEPTH

          protected static final int MAX_DEPTH

      See Also:
        Constant Field Values

    - #### MIN_SNS_INDEX

          protected static final int MIN_SNS_INDEX

      See Also:
        Constant Field Values

    - #### MAX_SNS_INDEX

          protected static final int MAX_SNS_INDEX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BasicLuceneQueryFactory

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

      Parameters:
        `context` -
        `searchFactory` -
        `version` - the Lucene version

  - ### Method Detail

    - #### pathAsString

          protected final String pathAsString(Path path)

    - #### getFullTextSearchAnalyzer

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

      Specified by:
        `getFullTextSearchAnalyzer` in class `LuceneQueryFactory`

    - #### fullTextFieldName

          protected String fullTextFieldName(String propertyName)

      Create the field name that will be used to store the full-text searchable property values.

      If a property name is provided, then the resulting field name is generated from the `full-text prefix` and the property name. Otherwise, the result is the field name where the full-text terms for the entire node are indexed.

      Specified by:
        `fullTextFieldName` in class `LuceneQueryFactory`
      Parameters:
        `propertyName` - the name of the property; may not null
      Returns:
        the field name for the full-text searchable property values; never null

    - #### findAllNodesBelow

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

      Description copied from class: `LuceneQueryFactory`
      Return a query that will find all documents representing nodes below the supplied path.
      Specified by:
        `findAllNodesBelow` in class `LuceneQueryFactory`
      Parameters:
        `ancestorPath` - the path of the ancestor node; never null
      Returns:
        the query; never null

    - #### findAllNodesAtOrBelow

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

      Description copied from class: `LuceneQueryFactory`
      Return a query that will find all documents representing nodes at or below the supplied path.
      Specified by:
        `findAllNodesAtOrBelow` in class `LuceneQueryFactory`
      Parameters:
        `ancestorPath` - the path of the ancestor node; never null
      Returns:
        the query; never null

    - #### findChildNodes

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

      Description copied from class: `LuceneQueryFactory`
      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.
      Specified by:
        `findChildNodes` in class `LuceneQueryFactory`
      Parameters:
        `parentPath` - the path of the parent node.
      Returns:
        the query; never null

    - #### findNodeAt

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

      Description copied from class: `LuceneQueryFactory`
      Create a query that can be used to find the one document (or node) that exists at the exact path supplied.
      Specified by:
        `findNodeAt` in class `LuceneQueryFactory`
      Parameters:
        `path` - the path of the node
      Returns:
        the query; never null

    - #### findNodesLike

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

      Description copied from class: `LuceneQueryFactory`
      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 '?'.
      Specified by:
        `findNodesLike` in class `LuceneQueryFactory`
      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

    - #### findNodesLike

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

    - #### findNodesWith

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

      Description copied from class: `LuceneQueryFactory`
      Create a query that finds documents with fields whose lengths fit the supplied operator/value criteria.
      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`
      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

    - #### findNodesWith

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

      Description copied from class: `LuceneQueryFactory`
      Create a query that finds documents with fields whose values fit the supplied operator/value criteria.
      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`
      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

    - #### findNodesWith

          protected org.apache.lucene.search.Query findNodesWith(SelectorName selectorName,
                                                     PropertyValue propertyValue,
                                                     Operator operator,
                                                     Object value,
                                                     CaseOperations.CaseOperation caseOperation,
                                                     PropertyType valueType,
                                                     Schemata.Column metadata)

    - #### findNodesWith

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

      Description copied from class: `LuceneQueryFactory`
      Create a query that finds documents with fields that are references that fit the supplied operator/value criteria.
      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`
      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

    - #### findNodesWithNumericRange

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

      Description copied from class: `LuceneQueryFactory`
      Create a query that finds documents with fields with values that are in the supplied range.
      Specified by:
        `findNodesWithNumericRange` in class `LuceneQueryFactory`
      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

    - #### findNodesWithNumericRange

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

      Description copied from class: `LuceneQueryFactory`
      Create a query that finds documents with fields with depths that are in the supplied range.
      Specified by:
        `findNodesWithNumericRange` in class `LuceneQueryFactory`
      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

    - #### findNodesWithNumericRange

          protected org.apache.lucene.search.Query findNodesWithNumericRange(SelectorName selectorName,
                                                                 String field,
                                                                 Object lowerValue,
                                                                 Object upperValue,
                                                                 boolean includesLower,
                                                                 boolean includesUpper)

    - #### likeExpresionForWildcardPath

          protected String likeExpresionForWildcardPath(String path)

    - #### findNodesWith

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

      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`

    - #### findNodesWith

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

      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`

    - #### findNodesWith

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

      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`

    - #### findNodesWith

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

      Specified by:
        `findNodesWith` in class `LuceneQueryFactory`

    - #### createSnsIndexQuery

          protected org.apache.lucene.search.Query createSnsIndexQuery(String likeExpression)

      Utility method to generate a query against the SNS indexes. This method attempts to generate a query that works most efficiently, depending upon the supplied expression. For example, if the supplied expression is just "[3]", then a range query is used to find all values matching '3'. However, if "[3_]" is used (where '_' matches any single-character, or digit in this case), then a range query is used to find all values between '30' and '39'. Similarly, if "[3%]" is used, then a regular expression query is used.
      Parameters:
        `likeExpression` - the expression that uses the JCR 2.0 LIKE representation, and which includes the leading '[' and trailing ']' characters
      Returns:
        the query, or null if the expression cannot be represented as a query

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