Class MutableFacetResultNode
- java.lang.Object
-
- org.apache.lucene.facet.search.results.MutableFacetResultNode
-
- All Implemented Interfaces:
FacetResultNode
public class MutableFacetResultNode extends Object implements FacetResultNode
Mutable implementation for Result of faceted search for a certain taxonomy node.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description MutableFacetResultNode(int ordinal, double value)Create a Facet Result Node.MutableFacetResultNode(int ordinal, double value, double residue, CategoryPath label, List<FacetResultNode> subResults)Create a Facet Result Node.MutableFacetResultNode(FacetResultNode other, boolean takeSubResults)Create a mutable facet result node from another result node
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendSubResult(FacetResultNode subRes)Append a sub result (as last).CategoryPathgetLabel()Category path of the category of this result, or null if not computed, because the application did not request to compute it.CategoryPathgetLabel(TaxonomyReader taxonomyReader)Category path of the category of this result.intgetNumSubResults()Number of sub resultsintgetOrdinal()Ordinal of the category of this result.doublegetResidue()Value of screened out sub results.Iterable<? extends FacetResultNode>getSubResults()Contained sub results.doublegetValue()Value of this result - usually either count or a value derived from some computing on the association of it.voidincreaseResidue(double addedResidue)increase the residue for this result.voidincreaseValue(double addedValue)increase the value for this result.voidinsertSubResult(FacetResultNode subRes)Insert sub result (as first).voidreset(int ordinal, double value)Reset a facet Result Node.voidsetLabel(CategoryPath label)Set the label of the category of this result.voidsetResidue(double residue)Set the residue.voidsetSubResults(List<FacetResultNode> subResults)Set the sub results.voidsetValue(double value)Set the value of this result.static MutableFacetResultNodetoImpl(FacetResultNode frn)Internal utility: turn a result node into an implementation class with richer API that allows modifying it.StringtoString()StringtoString(String prefix)String representation of this facet result node.voidtrimSubResults(int size)Trim sub results to a given size.
-
-
-
Constructor Detail
-
MutableFacetResultNode
public MutableFacetResultNode(int ordinal, double value)Create a Facet Result Node.- Parameters:
ordinal- ordinal in the taxonomy of the category of this result.value- value this result.
-
MutableFacetResultNode
public MutableFacetResultNode(int ordinal, double value, double residue, CategoryPath label, List<FacetResultNode> subResults)Create a Facet Result Node.- Parameters:
ordinal- ordinal in the taxonomy of the category of this result.value- value of this result.residue- Value of screened out sub results.label- label of the category path of this result.subResults- - sub results, usually descendants, sometimes child results, of this result - depending on the request.
-
MutableFacetResultNode
public MutableFacetResultNode(FacetResultNode other, boolean takeSubResults)
Create a mutable facet result node from another result node- Parameters:
other- other result node to copy fromtakeSubResults- set to true to take also sub results of other node
-
-
Method Detail
-
reset
public void reset(int ordinal, double value)Reset a facet Result Node.Used at the population of facet results, not intended for regular use by applications.
- Parameters:
ordinal- ordinal in the taxonomy of the category of this result.value- value of this result.
-
toString
public String toString(String prefix)
Description copied from interface:FacetResultNodeString representation of this facet result node. Use with caution: might return a very long string.- Specified by:
toStringin interfaceFacetResultNode- Parameters:
prefix- prefix for each result line
-
getOrdinal
public final int getOrdinal()
Description copied from interface:FacetResultNodeOrdinal of the category of this result.- Specified by:
getOrdinalin interfaceFacetResultNode
-
getLabel
public final CategoryPath getLabel()
Description copied from interface:FacetResultNodeCategory path of the category of this result, or null if not computed, because the application did not request to compute it. To force computing the label in case not yet computed useFacetResultNode.getLabel(TaxonomyReader).- Specified by:
getLabelin interfaceFacetResultNode- See Also:
FacetRequest.getNumLabel(),FacetResultNode.getLabel(TaxonomyReader)
-
setLabel
public void setLabel(CategoryPath label)
Set the label of the category of this result.- Parameters:
label- the label to set.- See Also:
getLabel()
-
getValue
public final double getValue()
Description copied from interface:FacetResultNodeValue of this result - usually either count or a value derived from some computing on the association of it.- Specified by:
getValuein interfaceFacetResultNode
-
setValue
public void setValue(double value)
Set the value of this result.- Specified by:
setValuein interfaceFacetResultNode- Parameters:
value- the value to set- See Also:
getValue()
-
increaseValue
public void increaseValue(double addedValue)
increase the value for this result.- Parameters:
addedValue- the value to add- See Also:
getValue()
-
getResidue
public final double getResidue()
Description copied from interface:FacetResultNodeValue of screened out sub results.If only part of valid results are returned, e.g. because top K were requested, provide info on "what else is there under this result node".
- Specified by:
getResiduein interfaceFacetResultNode
-
setResidue
public void setResidue(double residue)
Set the residue.- Parameters:
residue- the residue to set- See Also:
getResidue()
-
increaseResidue
public void increaseResidue(double addedResidue)
increase the residue for this result.- Parameters:
addedResidue- the residue to add- See Also:
getResidue()
-
getSubResults
public final Iterable<? extends FacetResultNode> getSubResults()
Description copied from interface:FacetResultNodeContained sub results. These are either child facets, if a tree result was requested, or simply descendants, in case tree result was not requested. In the first case, all returned are both descendants of this node in the taxonomy and siblings of each other in the taxonomy. In the latter case they are only guaranteed to be descendants of this node in the taxonomy.- Specified by:
getSubResultsin interfaceFacetResultNode
-
trimSubResults
public void trimSubResults(int size)
Trim sub results to a given size.Note: Although the
getResidue()is not guaranteed to be accurate, it is worth fixing it, as possible, by taking under account the trimmed sub-nodes.
-
setSubResults
public void setSubResults(List<FacetResultNode> subResults)
Set the sub results.- Parameters:
subResults- the sub-results to set
-
appendSubResult
public void appendSubResult(FacetResultNode subRes)
Append a sub result (as last).- Parameters:
subRes- sub-result to be appended
-
insertSubResult
public void insertSubResult(FacetResultNode subRes)
Insert sub result (as first).- Parameters:
subRes- sub-result to be inserted
-
getLabel
public final CategoryPath getLabel(TaxonomyReader taxonomyReader) throws IOException
Description copied from interface:FacetResultNodeCategory path of the category of this result. If not already computed, will be computed now.Use with caution: loading a label for results is costly, performance wise. Therefore force labels loading only when really needed.
- Specified by:
getLabelin interfaceFacetResultNode- Parameters:
taxonomyReader- taxonomy reader for forcing (lazy) labeling of this result.- Throws:
IOException- on error- See Also:
FacetRequest.getNumLabel()
-
getNumSubResults
public final int getNumSubResults()
Description copied from interface:FacetResultNodeNumber of sub results- Specified by:
getNumSubResultsin interfaceFacetResultNode
-
toImpl
public static MutableFacetResultNode toImpl(FacetResultNode frn)
Internal utility: turn a result node into an implementation class with richer API that allows modifying it.In case that input result node is already of an implementation class only casting is done, but in any case we pay the price of checking "instance of".
- Parameters:
frn- facet result node to be turned into an implementation class object
-
-