Home | Trees | Indices | Help |
|
---|
|
object --+ | SearchConnection
A connection to the search engine for searching.
The connection will access a view of the database.
Nested Classes | |
ExpandDecider |
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Variables | |
OP_AND = 0
|
|
OP_OR = 1
|
Properties | |
Inherited from |
Method Details |
Create a new connection to the index for searching. There may only an arbitrary number of search connections for a particular database open at a given time (regardless of whether there is a connection for indexing open as well). If the database doesn't exist, an exception will be raised.
|
Append a callback to the list of close handlers. These will be called when the SearchConnection is closed. This happens when the close() method is called, or when the SearchConnection object is deleted. The callback will be passed two arguments: the path to the SearchConnection object, and the userdata supplied to this method. The handlers will be called in the order in which they were added. The handlers will be called after the connection has been closed, so cannot prevent it closing: their return value will be ignored. In addition, they should not raise any exceptions. |
Reopen the connection. This updates the revision of the index which the connection references to the latest flushed revision. |
Close the connection to the database. It is important to call this method before allowing the class to be garbage collected to ensure that the connection is cleaned up promptly. No other methods may be called on the connection after this has been called. (It is permissible to call close() multiple times, but only the first call will have any effect.) If an exception occurs, the database will be closed, but changes since the last call to flush may be lost. |
Count the number of documents in the database. This count will include documents which have been added or removed but not yet flushed(). |
Build a composite query from a list of queries. The queries are combined with the supplied operator, which is either SearchConnection.OP_AND or SearchConnection.OP_OR. |
Build a query which modifies the weights of a subquery. This produces a query which returns the same documents as the subquery, and in the same order, but with the weights assigned to each document multiplied by the value of "multiplier". "multiplier" may be any floating point value, but negative values will be clipped to 0, since Xapian doesn't support negative weights. This can be useful when producing queries to be combined with query_composite, because it allows the relative importance of parts of the query to be adjusted. |
Filter a query with another query. If exclude is False (or not specified), documents will only match the resulting query if they match the both the first and second query: the results of the first query are "filtered" to only include those which also match the second query. If exclude is True, documents will only match the resulting query if they match the first query, but not the second query: the results of the first query are "filtered" to only include those which do not match the second query. Documents will always be weighted according to only the first query.
|
Adjust the weights of one query with a secondary query. Documents will be returned from the resulting query if and only if they match the primary query (specified by the "primary" parameter). However, the weights (and hence, the relevance rankings) of the documents will be adjusted by adding weights from the secondary query (specified by the "secondary" parameter). |
Create a query for a range search. This creates a query which matches only those documents which have a field value in the specified range. Begin and end must be appropriate values for the field, according to the 'type' parameter supplied to the SORTABLE action for the field. The begin and end values are both inclusive - any documents with a value equal to begin or end will be returned (unless end is less than begin, in which case no documents will be returned). Begin or end may be set to None in order to create an open-ended range. (They may also both be set to None, which will generate a query which matches all documents containing any value for the field.) |
Create a query for a facet value. This creates a query which matches only those documents which have a facet value in the specified range. For a numeric range facet, val should be a tuple holding the start and end of the range, or a comma separated string holding two floating point values. For other facets, val should be the value to look for. The start and end values are both inclusive - any documents with a value equal to start or end will be returned (unless end is less than start, in which case no documents will be returned). |
Parse a query string. This is intended for parsing queries entered by a user. If you wish to combine structured queries, it is generally better to use the other query building methods, such as query_composite (though you may wish to create parts of the query to combine with such methods with this method). The string passed to this method can have various operators in it. In particular, it may contain field specifiers (ie, field names, followed by a colon, followed by some text to search for in that field). For example, if "author" is a field in the database, the search string could contain "author:richard", and this would be interpreted as "search for richard in the author field". By default, any fields in the database which are indexed with INDEX_EXACT or INDEX_FREETEXT will be available for field specific searching in this way - however, this can be modified using the "allow" or "deny" parameters, and also by the allow_field_specific tag on INDEX_FREETEXT fields. Any text which isn't prefixed by a field specifier is used to search the "default set" of fields. By default, this is the full set of fields in the database which are indexed with INDEX_FREETEXT and for which the search_by_default flag set (ie, if the text is found in any of those fields, the query will match). However, this may be modified with the "default_allow" and "default_deny" parameters. (Note that fields which are indexed with INDEX_EXACT aren't allowed to be used in the default list of fields.)
Only one of Only one of If any of the entries in Returns a Query object, which may be passed to the search() method, or combined with other queries. |
Get a query which returns documents which are similar to others. The list of document IDs to base the similarity search on is given in
By default, all fields which have been indexed for freetext searching
will be used for the similarity calculation. The list of fields used
for this can be customised using the
For convenience, any of Regardless of the setting of |
Get a set of "significant" terms for a document, or documents. This has a similar interface to query_similar(): it takes a list of ids, and an optional specification of a set of fields to consider. Instead of returning a query, it returns a list of terms from the document (or documents), which appear "significant". Roughly, in this situation significant means that the terms occur more frequently in the specified document than in the rest of the corpus. The list is in decreasing order of "significance". By default, all terms related to fields which have been indexed for
freetext searching will be considered for the list of significant
terms. The list of fields used for this can be customised using the
For convenience, any of Regardless of the setting of The maximum number of terms to return may be specified by the maxterms parameter. |
A query which matches no documents in the database. This may be useful as a placeholder in various situations. |
Correct a query spelling. This returns a version of the query string with any misspelt words corrected.
Only one of Only one of If any of the entries in Note that it is possible that the resulting spell-corrected query will still match no documents - the user should usually check that some documents are matched by the corrected query before suggesting it to users. |
Perform a search, for documents matching a query.
If neither 'allowfacets' or 'denyfacets' is specified, all fields holding facets will be considered (but see 'usesubfacets'). |
Get an iterator which returns all the ids in the database. The unqiue_ids are currently returned in binary lexicographical sort order, but this should not be relied on. Note that the iterator returned by this method may raise a xapian.DatabaseModifiedError exception if modifications are committed to the database while the iteration is in progress. If this happens, the search connection must be reopened (by calling reopen) and the iteration restarted. |
Get the document with the specified unique ID. Raises a KeyError if there is no such document. Otherwise, it returns a ProcessedDocument. |
Get an iterator over the synonyms.
The iterator returns 2-tuples, in which the first item is the key (ie, a 2-tuple holding the term or terms which will be synonym expanded, followed by the fieldname specified (or None if no fieldname)), and the second item is a tuple of strings holding the synonyms for the first item. These return values are suitable for the dict() builtin, so you can write things like: >>> conn = _indexerconnection.IndexerConnection('foo') >>> conn.add_synonym('foo', 'bar') >>> conn.add_synonym('foo bar', 'baz') >>> conn.add_synonym('foo bar', 'foo baz') >>> conn.flush() >>> conn = SearchConnection('foo') >>> dict(conn.iter_synonyms()) {('foo', None): ('bar',), ('foo bar', None): ('baz', 'foo baz')} |
Get an item of metadata stored in the connection. This returns a value stored by a previous call to IndexerConnection.set_metadata. If the value is not found, this will return the empty string. |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Tue Apr 29 09:21:55 2008 | http://epydoc.sourceforge.net |