org.apache.solr.search.join

## Class GraphQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.solr.search.join.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.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `GraphQuery.GraphQueryWeight`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `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(Query q, String fromField, String toField, Query traversalFilter)` Create a graph query with a traversal filter applied while traversing the frontier.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Weight` | `createWeight(IndexSearcher searcher, boolean needsScores)`
    `boolean` | `equals(Object other)`
    `String` | `getFromField()`
    `int` | `getMaxDepth()`
    `Query` | `getQ()`
    `String` | `getToField()`
    `Query` | `getTraversalFilter()`
    `int` | `hashCode()`
    `boolean` | `isOnlyLeafNodes()`
    `boolean` | `isReturnRoot()`
    `boolean` | `isUseAutn()`
    `void` | `setFromField(String fromField)`
    `void` | `setMaxDepth(int maxDepth)`
    `void` | `setOnlyLeafNodes(boolean onlyLeafNodes)`
    `void` | `setQ(Query q)`
    `void` | `setReturnRoot(boolean returnRoot)`
    `void` | `setToField(String toField)`
    `void` | `setTraversalFilter(Query traversalFilter)`
    `void` | `setUseAutn(boolean useAutn)`
    `String` | `toString(String field)`

    - ### Methods inherited from class org.apache.lucene.search.Query

      `classHash, rewrite, sameClassAs, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 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

    - #### createWeight

          public Weight createWeight(IndexSearcher searcher,
                                     boolean needsScores)
                              throws IOException

      Overrides:
        `createWeight` in class `Query`
      Throws:
        `IOException`

    - #### toString

          public String toString(String field)

      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.

    - #### setTraversalFilter

          public void setTraversalFilter(Query traversalFilter)

    - #### getQ

          public Query getQ()

    - #### setQ

          public void setQ(Query q)

    - #### getFromField

          public String getFromField()

      Returns:
        The field that contains the node id

    - #### setFromField

          public void setFromField(String fromField)

    - #### getToField

          public String getToField()

      Returns:
        the field that contains the edge id(s)

    - #### setToField

          public void setToField(String toField)

    - #### getMaxDepth

          public int getMaxDepth()

      Returns:
        Max depth for traversal, -1 for infinite!

    - #### setMaxDepth

          public void setMaxDepth(int maxDepth)

    - #### 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.

    - #### setOnlyLeafNodes

          public void setOnlyLeafNodes(boolean onlyLeafNodes)

    - #### 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.

    - #### setReturnRoot

          public void setReturnRoot(boolean returnRoot)

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in class `Query`

    - #### equals

          public boolean equals(Object other)

      Specified by:
        `equals` in class `Query`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.