Package 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 org.apache.lucene.search.QueryGraphQuery - 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 Description protected classGraphQuery.GraphQueryWeight
-
Constructor Summary
Constructors Constructor Description GraphQuery(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.lucene.search.WeightcreateWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost)booleanequals(Object other)StringgetFromField()intgetMaxDepth()org.apache.lucene.search.QuerygetQ()StringgetToField()org.apache.lucene.search.QuerygetTraversalFilter()inthashCode()booleanisOnlyLeafNodes()booleanisReturnRoot()booleanisUseAutn()voidsetFromField(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)StringtoString(String field)voidvisit(org.apache.lucene.search.QueryVisitor visitor)
-
-
-
Constructor Detail
-
GraphQuery
public GraphQuery(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 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 Detail
-
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
public String toString(String field)
- 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
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:
hashCodein classorg.apache.lucene.search.Query
-
equals
public boolean equals(Object other)
- Specified by:
equalsin classorg.apache.lucene.search.Query
-
visit
public void visit(org.apache.lucene.search.QueryVisitor visitor)
- Overrides:
visitin classorg.apache.lucene.search.Query
-
-