Package xappy :: Module searchconnection :: Class SearchResults
[frames] | no frames]

Class SearchResults

source code

object --+
         |
        SearchResults

A set of results of a search.

Instance Methods
 
__init__(self, conn, enq, query, mset, fieldmappings, tagspy, tagfields, facetspy, facetfields, facethierarchy, facetassocs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__repr__(self)
repr(x)
source code
 
get_hit(self, index)
Get the hit with a given index.
source code
 
__getitem__(self, index)
Get the hit with a given index.
source code
 
__iter__(self)
Get an iterator over the hits in the search result.
source code
 
__len__(self)
Get the number of hits in the search result.
source code
 
get_top_tags(self, field, maxtags)
Get the most frequent tags in a given field.
source code
 
get_suggested_facets(self, maxfacets=5, desired_num_of_categories=7, required_facets=None)
Get a suggested set of facets, to present to the user.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties
  more_matches
Check whether there are further matches after those in this result set.
  startrank
Get the rank of the first item in the search results.
  endrank
Get the rank of the item after the end of the search results.
  matches_lower_bound
Get a lower bound on the total number of matching documents.
  matches_upper_bound
Get an upper bound on the total number of matching documents.
  matches_human_readable_estimate
Get a human readable estimate of the number of matching documents.
  matches_estimated
Get an estimate for the total number of matching documents.
  estimate_is_exact
Check whether the estimated number of matching documents is exact.

Inherited from object: __class__

Method Details

__init__(self, conn, enq, query, mset, fieldmappings, tagspy, tagfields, facetspy, facetfields, facethierarchy, facetassocs)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

__iter__(self)

source code 

Get an iterator over the hits in the search result.

The iterator returns the results in increasing order of rank.

__len__(self)
(Length operator)

source code 

Get the number of hits in the search result.

Note that this is not (usually) the number of matching documents for the search. If startrank is non-zero, it's not even the rank of the last document in the search result. It's simply the number of hits stored in the search result.

It is, however, the number of items returned by the iterator produced by calling iter() on this SearchResults object.

get_top_tags(self, field, maxtags)

source code 

Get the most frequent tags in a given field.

  • field - the field to get tags for. This must have been specified in the "gettags" argument of the search() call.
  • maxtags - the maximum number of tags to return.

Returns a sequence of 2-item tuples, in which the first item in the tuple is the tag, and the second is the frequency of the tag in the matches seen (as an integer).

get_suggested_facets(self, maxfacets=5, desired_num_of_categories=7, required_facets=None)

source code 

Get a suggested set of facets, to present to the user.

This returns a list, in descending order of the usefulness of the facet, in which each item is a tuple holding:

  • fieldname of facet.

  • sequence of 2-tuples holding the suggested values or ranges for that field:

    For facets of type 'string', the first item in the 2-tuple will simply be the string supplied when the facet value was added to its document. For facets of type 'float', it will be a 2-tuple, holding floats giving the start and end of the suggested value range.

    The second item in the 2-tuple will be the frequency of the facet value or range in the result set.

If required_facets is not None, it must be a field name, or a sequence of field names. Any field names mentioned in required_facets will be returned if there are any facet values at all in the search results for that field. The facet will only be omitted if there are no facet values at all for the field.

The value of maxfacets will be respected as far as possible; the exception is that if there are too many fields listed in required_facets with at least one value in the search results, extra facets will be returned (ie, obeying the required_facets parameter is considered more important than the maxfacets parameter).

If facet_hierarchy was indicated when search() was called, and the query included facets, then only subfacets of those query facets and top-level facets will be included in the returned list. Furthermore top-level facets will only be returned if there are remaining places in the list after it has been filled with subfacets. Note that required_facets is still respected regardless of the facet hierarchy.

If a query type was specified when search() was called, and the query included facets, then facets with an association of Never to the query type are never returned, even if mentioned in required_facets. Facets with an association of Preferred are listed before others in the returned list.


Property Details

more_matches

Check whether there are further matches after those in this result set.
Get Method:
xappy.searchconnection.SearchResults._get_more_matches(self)

startrank

Get the rank of the first item in the search results.

This corresponds to the "startrank" parameter passed to the search() method.

Get Method:
xappy.searchconnection.SearchResults._get_startrank(self)

endrank

Get the rank of the item after the end of the search results.

If there are sufficient results in the index, this corresponds to the "endrank" parameter passed to the search() method.

Get Method:
xappy.searchconnection.SearchResults._get_endrank(self)

matches_lower_bound

Get a lower bound on the total number of matching documents.
Get Method:
xappy.searchconnection.SearchResults._get_lower_bound(self)

matches_upper_bound

Get an upper bound on the total number of matching documents.
Get Method:
xappy.searchconnection.SearchResults._get_upper_bound(self)

matches_human_readable_estimate

Get a human readable estimate of the number of matching documents.

This consists of the value returned by the "matches_estimated" property, rounded to an appropriate number of significant digits (as determined by the values of the "matches_lower_bound" and "matches_upper_bound" properties).

Get Method:
xappy.searchconnection.SearchResults._get_human_readable_estimate(self)

matches_estimated

Get an estimate for the total number of matching documents.
Get Method:
xappy.searchconnection.SearchResults._get_estimated(self)

estimate_is_exact

Check whether the estimated number of matching documents is exact.

If this returns true, the estimate given by the matches_estimated property is guaranteed to be correct.

If this returns false, it is possible that the actual number of matching documents is different from the number given by the matches_estimated property.

Get Method:
xappy.searchconnection.SearchResults._estimate_is_exact(self)