SMILA 1.0 API documentation

org.eclipse.smila.search.api.helper
Class ResultBuilder

java.lang.Object
  extended by org.eclipse.smila.search.api.helper.ResultAccessor
      extended by org.eclipse.smila.search.api.helper.ResultBuilder
Direct Known Subclasses:
SolrResultBuilder

public class ResultBuilder
extends ResultAccessor

wrapper helper class to build the result record. This is intentionally a subclass of the ResultAccessor as to also provide read access to the props that are set here.


Field Summary
 
Fields inherited from class org.eclipse.smila.search.api.helper.ResultAccessor
_result
 
Constructor Summary
ResultBuilder(java.lang.String workflowName, Record result)
          Creates a new builder and adds an AnySeq for the SearchResultConstants.RECORDS.
 
Method Summary
 AnySeq addFacet(java.lang.String facetName)
          Adds facets Seq with the given name and returns it.
 AnyMap addFacetValue(AnySeq facet, Any value, java.lang.Long count)
          Adds the map containing the count and value for the facet value.
 AnyMap addFacetValue(AnySeq facet, java.lang.Object value, java.lang.Long count)
          Adds the map containing the count and value for the facet value.
 AnySeq addGroup(java.lang.String groupCommand)
          Create and return an AnySeq like RecordMetadata/groupCommand.
 AnySeq addGroup(java.lang.String groupName, java.lang.String groupCommand)
          Create and return an AnySeq like RecordMetadata/groupName/groupCommand.
 AnyMap addGroupResults(AnySeq group, Any value, java.lang.Long count, AnySeq results)
          Add a group to the AnySeq group with value, count and results.
 void addHighlight(AnyMap resultItem, java.lang.String attribute, AnyMap highlight)
          Add highlight result to result item.
 void addHighlightText(AnyMap resultItem, java.lang.String attribute, java.util.List<java.lang.String> text)
          Add multiple highlight texts to result item.
 void addHighlightText(AnyMap resultItem, java.lang.String attribute, java.lang.String text)
          Add highlight text to result item.
 AnyMap addNestedGroup(AnySeq group, Any value, java.lang.Long count, AnyMap nestedGroup)
          Add a group to the AnySeq group with value, count and a nested group.
 AnyMap addResultItem(java.lang.String id, java.lang.Double score)
          Adds a new result item to the list. the given args are mandatory and will be set at the item.
 void setCount(java.lang.Long count)
          sets value for SearchResultConstants.COUNT.
 void setRuntime(java.lang.Long millis)
          sets value for SearchResultConstants.RUNTIME.
 
Methods inherited from class org.eclipse.smila.search.api.helper.ResultAccessor
getCount, getFacets, getGroups, getIndexSize, getNumberOfRecords, getQuery, getResult, getResultRecord, getResultRecords, getRuntime, getWorkflowName, hasQuery, hasRecords
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultBuilder

public ResultBuilder(java.lang.String workflowName,
                     Record result)
Creates a new builder and adds an AnySeq for the SearchResultConstants.RECORDS.

Parameters:
workflowName -
result -
Method Detail

addResultItem

public AnyMap addResultItem(java.lang.String id,
                            java.lang.Double score)
Adds a new result item to the list. the given args are mandatory and will be set at the item.

Returns:
the map containing the id and score/weight under their proper names.

addHighlightText

public void addHighlightText(AnyMap resultItem,
                             java.lang.String attribute,
                             java.lang.String text)
Add highlight text to result item.

Parameters:
resultItem - the AnyMap result item.
attribute - the highlighted attribute.
text - the highlight text.

addHighlightText

public void addHighlightText(AnyMap resultItem,
                             java.lang.String attribute,
                             java.util.List<java.lang.String> text)
Add multiple highlight texts to result item.

Parameters:
resultItem - the AnyMap result item.
attribute - the highlighted attribute.
text - a List containing highlight texts.

addHighlight

public void addHighlight(AnyMap resultItem,
                         java.lang.String attribute,
                         AnyMap highlight)
Add highlight result to result item.

Parameters:
resultItem - the AnyMap result item.
attribute - the highlighted attribute.
highlight - the highlight result.

setCount

public void setCount(java.lang.Long count)
sets value for SearchResultConstants.COUNT.


setRuntime

public void setRuntime(java.lang.Long millis)
sets value for SearchResultConstants.RUNTIME.


addFacet

public AnySeq addFacet(java.lang.String facetName)
Adds facets Seq with the given name and returns it. The facet map is created on the fly if needs be.


addFacetValue

public AnyMap addFacetValue(AnySeq facet,
                            Any value,
                            java.lang.Long count)
Adds the map containing the count and value for the facet value.

Parameters:
facet - NullArgumentException if null
value - NullArgumentException if null
count - if null the count property is not set
Returns:
the map of the added facet

addFacetValue

public AnyMap addFacetValue(AnySeq facet,
                            java.lang.Object value,
                            java.lang.Long count)
Adds the map containing the count and value for the facet value.

Parameters:
facet - any valid literal object that can be passed into DataFactory.autoConvertValue(Object)
Returns:
the map for added value containing the value and count

addGroup

public AnySeq addGroup(java.lang.String groupName,
                       java.lang.String groupCommand)
Create and return an AnySeq like RecordMetadata/groupName/groupCommand.

Parameters:
groupName - the group name.
groupCommand - the group command.
Returns:
AnySeq like RecordMetadata/groupName/groupCommand.

addGroup

public AnySeq addGroup(java.lang.String groupCommand)
Create and return an AnySeq like RecordMetadata/groupCommand.

Parameters:
groupCommand - the group name.
Returns:
AnySeq like RecordMetadata/groupCommand.

addGroupResults

public AnyMap addGroupResults(AnySeq group,
                              Any value,
                              java.lang.Long count,
                              AnySeq results)
Add a group to the AnySeq group with value, count and results.

Parameters:
group - the group to add to.
value - the value.
count - the count.
results - the results.
Returns:
the added group as AnyMap.

addNestedGroup

public AnyMap addNestedGroup(AnySeq group,
                             Any value,
                             java.lang.Long count,
                             AnyMap nestedGroup)
Add a group to the AnySeq group with value, count and a nested group.

Parameters:
group - the group to add to.
value - the value.
count - the count.
nestedGroup - the nested group.
Returns:
the added group as AnyMap.

SMILA 1.0 API documentation