org.apache.solr.search.join

Class GraphQuery



  • public class GraphQuery
    extends Query
    GraphQuery - search for nodes and traverse edges in an index. Params: fromField = the field that contains the node id toField = the field that contains the edge ids traversalFilter = a query that can be applied for each hop in the graph. maxDepth = the max depth to traverse. (start nodes is depth=1) onlyLeafNodes = only return documents that have no edge id values. returnRoot = if false, the documents matching the initial query will not be returned.
    • Constructor Detail

      • GraphQuery

        public GraphQuery(Query q,
                          String fromField,
                          String toField)
        Create a graph query q - the starting node query fromField - the field containing the node id toField - the field containing the edge ids
      • GraphQuery

        public GraphQuery(Query q,
                          String fromField,
                          String toField,
                          Query traversalFilter)
        Create a graph query with a traversal filter applied while traversing the frontier. q - the starting node query fromField - the field containing the node id toField - the field containing the edge ids traversalFilter - the filter to be applied on each iteration of the frontier.
    • Method Detail

      • toString

        public String toString(String field)
        Description copied from class: Query
        Prints a query to a string, with field assumed to be the default field and omitted.
        Specified by:
        toString in class Query
      • getTraversalFilter

        public Query getTraversalFilter()
        Returns:
        The query to be used as a filter for each hop in the graph.
      • getFromField

        public String getFromField()
        Returns:
        The field that contains the node id
      • getToField

        public String getToField()
        Returns:
        the field that contains the edge id(s)
      • getMaxDepth

        public int getMaxDepth()
        Returns:
        Max depth for traversal, -1 for infinite!
      • isUseAutn

        public boolean isUseAutn()
        Returns:
        If true , an automaton query will be compiled for each new frontier traversal this helps to avoid max boolean clause errors.
      • setUseAutn

        public void setUseAutn(boolean useAutn)
      • isOnlyLeafNodes

        public boolean isOnlyLeafNodes()
        Returns:
        if true only documents that do not have a value in the edge id field will be returned.
      • isReturnRoot

        public boolean isReturnRoot()
        Returns:
        if true the documents that matched the rootNodes query will be returned. o/w they will be removed from the result set.
      • equals

        public boolean equals(Object other)
        Description copied from class: Query
        Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly. Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical that other instance. Utility methods are provided for certain repetitive code.
        Specified by:
        equals in class Query
        See Also:
        Query.sameClassAs(Object), Query.classHash()