Package org.apache.solr.search.join
Class GraphQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.solr.search.join.GraphQuery
- All Implemented Interfaces:
SolrSearcherRequirer
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 -
Constructor Summary
ConstructorsConstructorDescriptionGraphQuery(org.apache.lucene.search.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 idsGraphQuery(org.apache.lucene.search.Query q, String fromField, String toField, org.apache.lucene.search.Query traversalFilter) Create a graph query with a traversal filter applied while traversing the frontier. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.search.WeightcreateWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost) booleanintorg.apache.lucene.search.QuerygetQ()org.apache.lucene.search.QueryinthashCode()booleanbooleanbooleanvoidsetFromField(String fromField) voidsetMaxDepth(int maxDepth) voidsetOnlyLeafNodes(boolean onlyLeafNodes) voidsetQ(org.apache.lucene.search.Query q) voidsetReturnRoot(boolean returnRoot) voidsetToField(String toField) voidsetTraversalFilter(org.apache.lucene.search.Query traversalFilter) voidsetUseAutn(boolean useAutn) voidvisit(org.apache.lucene.search.QueryVisitor visitor) Methods inherited from class org.apache.lucene.search.Query
classHash, rewrite, sameClassAs, toString
-
Constructor Details
-
GraphQuery
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(org.apache.lucene.search.Query q, String fromField, String toField, org.apache.lucene.search.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 Details
-
createWeight
public org.apache.lucene.search.Weight createWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost) throws IOException - Overrides:
createWeightin classorg.apache.lucene.search.Query- Throws:
IOException
-
toString
- Specified by:
toStringin classorg.apache.lucene.search.Query
-
getTraversalFilter
public org.apache.lucene.search.Query getTraversalFilter()- Returns:
- The query to be used as a filter for each hop in the graph.
-
setTraversalFilter
public void setTraversalFilter(org.apache.lucene.search.Query traversalFilter) -
getQ
public org.apache.lucene.search.Query getQ() -
setQ
public void setQ(org.apache.lucene.search.Query q) -
getFromField
- Returns:
- The field that contains the node id
-
setFromField
-
getToField
- Returns:
- the field that contains the edge id(s)
-
setToField
-
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:
hashCodein classorg.apache.lucene.search.Query
-
equals
- Specified by:
equalsin classorg.apache.lucene.search.Query
-
visit
public void visit(org.apache.lucene.search.QueryVisitor visitor) - Specified by:
visitin classorg.apache.lucene.search.Query
-