com.sun.labs.minion
Interface ResultSet

All Known Implementing Classes:
ResultSetImpl

public interface ResultSet

A class that holds the results of a search.


Method Summary
 java.util.Set<ResultsCluster> cluster(int k)
          Clusters the results into this set into a number of clusters.
 java.util.Set<ResultsCluster> cluster(java.lang.String field, int k)
          Clusters the results into this set into a number of clusters.
 ResultSet difference(ResultSet rs)
          Computes the difference of this result set and another result set.
 java.util.List<Result> getAllResults(boolean sorted)
          Gets all of the query results in the set.
 java.util.List<Result> getAllResults(boolean sorted, ResultsFilter rf)
          Gets all of the query results in the set.
 SearchEngine getEngine()
          Gets the search engine that generated this result set.
 int getNumDocs()
          Gets the number of documents that are in the whole index.
 QueryStats getQueryStats()
          Gets the statistics for the query that generated this set.
 long getQueryTime()
          Gets the amount of time that it took to evaluate the query, in milliseconds.
 java.util.List<Result> getResults(int start, int n)
          Gets a subset of the query results stored in this set.
 java.util.List<Result> getResults(int start, int n, ResultsFilter rf)
          Gets a subset of the query results stored in this set.
 java.util.Set<ResultsCluster> groupBy(java.lang.String field, boolean ignoreCase)
          Groups the results in this set into a number of clusters.
 ResultSet intersect(ResultSet rs)
          Computes the intersection of this result set with another result set.
 boolean querySyntaxError()
          Indicates whether the query contained a syntax error.
 void setResultsFilter(ResultsFilter rf)
          Sets the results filter that will be used to decide whether results should be returned from this set.
 void setScoreModifier(ScoreModifier sm)
          Sets the score modifier that will be used to modify the scores of the documents returned from this set.
 void setSortSpec(java.lang.String sortSpec)
          Sets the sorting specification used by this result set.
 int size()
          Gets the size of the results set, that is, the number of documents that matched the query.
 ResultSet union(ResultSet rs)
          Computes the intersection of this result set with another result set.
 ResultSet weight(float w)
          Weights the results in this set.
 

Method Detail

getEngine

SearchEngine getEngine()
Gets the search engine that generated this result set.

Returns:
the search engine that generated this result set.

setSortSpec

void setSortSpec(java.lang.String sortSpec)
Sets the sorting specification used by this result set.

Parameters:
sortSpec - a sorting specification for this result set.

setResultsFilter

void setResultsFilter(ResultsFilter rf)
Sets the results filter that will be used to decide whether results should be returned from this set.

Parameters:
rf - the results filter to use
See Also:
ResultsFilter, CompositeResultsFilter

setScoreModifier

void setScoreModifier(ScoreModifier sm)
Sets the score modifier that will be used to modify the scores of the documents returned from this set.

Parameters:
sm - the score modifier to use

getResults

java.util.List<Result> getResults(int start,
                                  int n)
                                  throws SearchEngineException
Gets a subset of the query results stored in this set.

Parameters:
start - The position in the set to start getting results, indexed from 0.
n - The number of results to get. Note that you may get less than this number of results if there are insufficient results in the set.
Returns:
A list of Result instances containing the search results.
Throws:
SearchEngineException - if there is some error getting the results.

getResults

java.util.List<Result> getResults(int start,
                                  int n,
                                  ResultsFilter rf)
                                  throws SearchEngineException
Gets a subset of the query results stored in this set.

Parameters:
start - The position in the set to start getting results, indexed from 0.
n - The number of results to get. Note that you may get less than this number of results if there are insufficient results in the set.
rf - a filter to apply against candidate results
Returns:
A list of Result instances containing the search results.
Throws:
SearchEngineException - if there is some error getting the results.

getAllResults

java.util.List<Result> getAllResults(boolean sorted)
                                     throws SearchEngineException
Gets all of the query results in the set. Note that this list may be very large!

Parameters:
sorted - If true, then the results will be sorted according to the sorting specification that was provided with the query. If false, then the results will be returned in an arbitrary order.
Returns:
A list of all the results in the set.
Throws:
SearchEngineException - if there is any error processing the result set

getAllResults

java.util.List<Result> getAllResults(boolean sorted,
                                     ResultsFilter rf)
                                     throws SearchEngineException
Gets all of the query results in the set. Note that this list may be very large!

Parameters:
sorted - If true, then the results will be sorted according to the sorting specification that was provided with the query. If false, then the results will be returned in an arbitrary order.
rf - a filter to apply against candidate results
Returns:
A list of all the results in the set.
Throws:
SearchEngineException - if there is any error processing the result set

getQueryStats

QueryStats getQueryStats()
Gets the statistics for the query that generated this set.

Returns:
the query statistics for the query that generated this set.

weight

ResultSet weight(float w)
Weights the results in this set.

Parameters:
w - a weight to apply multiplicatively to each of the scores in this set.
Returns:
a new result set with the weights applied. If no normalization is requested, then the scores for results in the new set may be greater than 0.

intersect

ResultSet intersect(ResultSet rs)
Computes the intersection of this result set with another result set.

Parameters:
rs - the result set with which this set will be intersected.
Returns:
a new result set containing only thos documents that occur in both this set and the set passed in. The score for documents in the returned set that occur in both sets will be the sum of the scores from the two sets. Note that this may result in scores greater than 1 for these documents!

union

ResultSet union(ResultSet rs)
Computes the intersection of this result set with another result set.

Parameters:
rs - the result set with which this set will be intersected.
Returns:
a new result set containing the documents that occur in either this set or the set passed in (or both). The score for documents in the returned set that occur in both sets will be the sum of the scores from the two sets. Note that this may result in scores greater than 1 for these documents!

difference

ResultSet difference(ResultSet rs)
Computes the difference of this result set and another result set.

Parameters:
rs - the result set with which this set will be intersected.
Returns:
a new result set containing the documents that occur in this set, but not the set passed in.

querySyntaxError

boolean querySyntaxError()
Indicates whether the query contained a syntax error.

Returns:
true if there was such an error, false otherwise.

size

int size()
Gets the size of the results set, that is, the number of documents that matched the query. If this number is 0, it may be worthwhile to see if the reason is that there was a syntax error in the query.

Returns:
The number of documents matching the query.
See Also:
querySyntaxError()

getNumDocs

int getNumDocs()
Gets the number of documents that are in the whole index.

Returns:
the number of documents in the entire collection

getQueryTime

long getQueryTime()
Gets the amount of time that it took to evaluate the query, in milliseconds.

Returns:
the amount of time that it took to evaluate this query, in milliseconds

cluster

java.util.Set<ResultsCluster> cluster(int k)
                                      throws SearchEngineException
Clusters the results into this set into a number of clusters. The algorithm used depends on how the engine that generated this set of results is configured.

Parameters:
k - the maximum number of clusters to return
Returns:
a set of clusters containing the results in this set. The number of clusters returned may be less than or equal to k
Throws:
SearchEngineException - if there are any errors generating the clusters
See Also:
ResultsCluster

cluster

java.util.Set<ResultsCluster> cluster(java.lang.String field,
                                      int k)
                                      throws SearchEngineException
Clusters the results into this set into a number of clusters. The algorithm used depends on how the engine that generated this set of results is configured.

Parameters:
field - the name of a vectored field upon which the clustering should be based. A value of null indicates that all vectored fields should be considered, while an empty string indicates that data in no explicit field should be considered.
k - the maximum number of clusters to return
Returns:
a set of clusters containing the results in this set. The number of clusters returned may be less than or equal to k
Throws:
SearchEngineException - if there are any errors generating the clusters
See Also:
ResultsCluster

groupBy

java.util.Set<ResultsCluster> groupBy(java.lang.String field,
                                      boolean ignoreCase)
                                      throws SearchEngineException
Groups the results in this set into a number of clusters. The results are broken into groups based on the values in the given field. If a result has more than one value for this field, then it will appear in the group for each field.

Parameters:
field - the name of the field for which we wish to group the results
ignoreCase - if true case will not be taken into account when grouping the results. Clearly, this only makes sense for string fields.
Returns:
a set of clusters grouped by the values of the given field
Throws:
SearchEngineException - if there are any errors grouping the results