__init__ constructor

init

Initializes a new in-memory Index instance.

def __init__(self):
    ...

Example

from groupdocs.search import Index

index = Index()

init

Initializes a new Index instance in memory with the specified index settings.

def __init__(self, settings):
    ...
Parameter Type Description
settings IndexSettings The index settings object.

Example

from groupdocs.search import Index, IndexSettings
from groupdocs.search.options import IndexType

settings = IndexSettings()
settings.index_type = IndexType.COMPACT_INDEX
index = Index(settings)

init

Initializes a new Index, creating a new or opening an existing index on disk.

def __init__(self, index_folder):
    ...
Parameter Type Description
index_folder str The index folder path.

Example

from groupdocs.search import Index

# Create or open an index located at "./index"
index = Index("./index")

init

Initializes a new Index with the specified folder and settings.

def __init__(self, index_folder, settings):
    ...
Parameter Type Description
index_folder str The index folder path.
settings IndexSettings The index settings object.

Example

from groupdocs.search import Index, IndexSettings
from groupdocs.search.options import IndexType

settings = IndexSettings()
settings.index_type = IndexType.COMPACT_INDEX
index = Index("./MyIndex", settings)

init

Initializes a new Index instance.

Loads an existing index from disk if overwrite_if_exists is False; otherwise creates a new index on disk.

def __init__(self, index_folder, overwrite_if_exists):
    ...
Parameter Type Description
index_folder str The index folder path.
overwrite_if_exists bool The flag of overwriting the index folder.

Example

from groupdocs.search import Index

# Create a new index, overwriting any existing index in the folder
index = Index("./MyIndex", overwrite_if_exists=True)

init

Initializes a new Index instance. Loads an existing index from disk if overwrite_if_exists is False; otherwise creates a new index on disk with the specified index settings.

def __init__(self, index_folder, settings, overwrite_if_exists):
    ...
Parameter Type Description
index_folder str The index folder path.
settings IndexSettings The index settings object.
overwrite_if_exists bool Flag indicating whether to overwrite the index folder.

Example

from groupdocs.search import Index, IndexSettings
from groupdocs.search.options import IndexType

index_folder = "./MyIndex"
settings = IndexSettings()
settings.index_type = IndexType.COMPACT_INDEX
index = Index(index_folder, settings, overwrite_if_exists=True)

See Also