index¶
API module for managing/viewing query indexes.
-
class
cloudant.index.
Index
(database, design_document_id=None, name=None, partitioned=None, **kwargs)¶ Bases:
object
Provides an interface for managing a JSON query index. Primarily meant to be used by the database convenience methods
create_query_index()
,delete_query_index()
, andget_query_indexes()
. It is recommended that you use those methods to manage an index rather than directly interfacing with Index objects.Parameters: - database (CloudantDatabase) – A Cloudant database instance used by the Index.
- design_document_id (str) – Optional identifier of the design document.
- name (str) – Optional name of the index.
- partitioned (bool) – Optional. Create as a partitioned index. Defaults
to
False
for both partitioned and non-partitioned databases. - kwargs – Options used to construct the index definition for the
purposes of index creation. For more details on valid options See
create_query_index()
.
-
as_a_dict
()¶ Displays the index as a dictionary. This includes the design document id, index name, index type, and index definition.
Returns: Dictionary representation of the index as a dictionary
-
create
()¶ Creates the current index in the remote database.
-
definition
¶ Displays the index definition. This could be either the definiton to be used to construct the index or the definition as it is returned by a GET request to the _index endpoint.
Returns: Index definition as a dictionary
-
delete
()¶ Removes the current index from the remote database.
-
design_document_id
¶ Displays the design document id.
Returns: Design document that this index belongs to
-
index_url
¶ Constructs and returns the index URL.
Returns: Index URL
-
name
¶ Displays the index name.
Returns: Name for this index
-
partitioned
¶ Check if this index is partitioned.
Returns: True
if index is partitioned, elseFalse
.Return type: bool
-
type
¶ Displays the index type.
Returns: Type of this index
-
class
cloudant.index.
SpecialIndex
(database, design_document_id=None, name='_all_docs', **kwargs)¶ Bases:
cloudant.index.Index
Provides an interface for viewing the “special” primary index of a database. Primarily meant to be used by the database convenience method
get_query_indexes()
. It is recommended that you use that method to view the “special” index rather than directly interfacing with the SpecialIndex object.-
create
()¶ A “special” index cannot be created. This method is disabled for a SpecialIndex object.
-
delete
()¶ A “special” index cannot be deleted. This method is disabled for a SpecialIndex object.
-
-
class
cloudant.index.
TextIndex
(database, design_document_id=None, name=None, **kwargs)¶ Bases:
cloudant.index.Index
Provides an interface for managing a text query index. Primarily meant to be used by the database convenience methods
create_query_index()
,delete_query_index()
, andget_query_indexes()
. It is recommended that you use those methods to manage an index rather than directly interfacing with TextIndex objects.Parameters: - database (CloudantDatabase) – A Cloudant database instance used by the TextIndex.
- design_document_id (str) – Optional identifier of the design document.
- name (str) – Optional name of the index.
- kwargs – Options used to construct the index definition for the
purposes of index creation. For more details on valid options See
create_query_index()
.