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.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 Description protected class
GraphQuery.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.Weight
createWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost)
boolean
equals(Object other)
String
getFromField()
int
getMaxDepth()
org.apache.lucene.search.Query
getQ()
String
getToField()
org.apache.lucene.search.Query
getTraversalFilter()
int
hashCode()
boolean
isOnlyLeafNodes()
boolean
isReturnRoot()
boolean
isUseAutn()
void
setFromField(String fromField)
void
setMaxDepth(int maxDepth)
void
setOnlyLeafNodes(boolean onlyLeafNodes)
void
setQ(org.apache.lucene.search.Query q)
void
setReturnRoot(boolean returnRoot)
void
setToField(String toField)
void
setTraversalFilter(org.apache.lucene.search.Query traversalFilter)
void
setUseAutn(boolean useAutn)
String
toString(String field)
void
visit(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:
createWeight
in classorg.apache.lucene.search.Query
- Throws:
IOException
-
toString
public String toString(String field)
- Specified by:
toString
in 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:
hashCode
in classorg.apache.lucene.search.Query
-
equals
public boolean equals(Object other)
- Specified by:
equals
in classorg.apache.lucene.search.Query
-
visit
public void visit(org.apache.lucene.search.QueryVisitor visitor)
- Specified by:
visit
in classorg.apache.lucene.search.Query
-
-