Contains the main functions/classes for creating, maintaining, and using an index.
The version number of the index format which this version of Whoosh writes.
Convenience function to create an index in a directory. Takes care of creating a FileStorage object for you.
Parameters: |
|
---|---|
Returns: |
Convenience function for opening an index in a directory. Takes care of creating a FileStorage object for you. dirname is the filename of the directory in containing the index. indexname is the name of the index to create; you only need to specify this if you have multiple indexes within the same storage object.
Parameters: |
|
---|---|
Returns: |
Returns True if dirname contains a Whoosh index.
Parameters: |
|
---|
Returns True if the given Storage object contains a Whoosh index.
Parameters: |
|
---|
Returns a tuple of (release_version, format_version), where release_version is the release version number of the Whoosh code that created the index – e.g. (0, 1, 24) – and format_version is the version number of the on-disk format used for the index – e.g. -102.
The second number (format version) may be useful for figuring out if you need to recreate an index because the format has changed. However, you can just try to open the index and see if you get an IndexVersionError exception.
Note that the release and format version are available as attributes on the Index object in Index.release and Index.version.
Parameters: |
|
---|---|
Returns: | ((major_ver, minor_ver, build_ver), format_ver) |
Returns a tuple of (release_version, format_version), where release_version is the release version number of the Whoosh code that created the index – e.g. (0, 1, 24) – and format_version is the version number of the on-disk format used for the index – e.g. -102.
The second number (format version) may be useful for figuring out if you need to recreate an index because the format has changed. However, you can just try to open the index and see if you get an IndexVersionError exception.
Note that the release and format version are available as attributes on the Index object in Index.release and Index.version.
Parameters: |
|
---|---|
Returns: | ((major_ver, minor_ver, build_ver), format_ver) |
Represents an indexed collection of documents.
Adds a field to the index’s schema.
Parameters: |
|
---|
Closes any open resources held by the Index object itself. This may not close all resources being used everywhere, for example by a Searcher object.
Returns the total number of UNDELETED documents in this index.
Returns the total number of documents, DELETED OR UNDELETED, in this index.
Returns the total length of the field across all documents.
Returns True if this index is empty (that is, it has never had any documents successfully written to it.
Parameters: |
|
---|
Returns the last modified time of the index, or -1 if the backend doesn’t support last-modified times.
Returns the generation number of the latest generation of this index, or -1 if the backend doesn’t support versioning.
Returns the maximum length of the field across all documents.
Optimizes this index, if necessary.
Returns an IndexReader object for this index.
Parameters: |
|
---|---|
Return type: |
Returns a new Index object representing the latest generation of this index (if this object is the latest generation, or the backend doesn’t support versioning, returns self).
Returns: | Index |
---|
Removes the named field from the index’s schema. Depending on the backend implementation, this may or may not actually remove existing data for the field from the index. Optimizing the index should always clear out existing data for a removed field.
Returns a Searcher object for this index. Keyword arguments are passed to the Searcher object’s constructor.
Return type: | whoosh.searching.Searcher |
---|
Returns True if this object represents the latest generation of this index. Returns False if this object is not the latest generation (that is, someone else has updated the index since you opened this object).
Parameters: |
|
---|
Returns an IndexWriter object for this index.
Return type: | whoosh.writing.IndexWriter |
---|
Raised when you try to work with an index that has no indexed terms.
Raised when you try to open an index using a format that the current version of Whoosh cannot read. That is, when the index you’re trying to open is either not backward or forward compatible with this version of Whoosh.
Raised when you try to commit changes to an index which is not the latest generation.
Generic index error.