## engine.IndexWriter


Inherited lucene IndexWriter.


Usage

``` python
engine.IndexWriter(
    directory,
    mode="a",
    analyzer=None,
    version=None,
    **attrs,
)
```


Supports setting fields parameters explicitly, so documents can be represented as dictionaries.

## Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| directory |  | directory path or lucene Directory | \- |
| mode |  | file mode (rwa), except updating (+) is implied | \- |
| analyzer |  | lucene Analyzer, default StandardAnalyzer | \- |
| version |  | lucene Version argument passed to IndexWriterConfig, default is latest \*\*attrs: additional attributes to set on IndexWriterConfig | \- |


## Methods

| Name | Description |
|----|----|
| [__iadd__()](#__iadd__) | Add directory (or reader, searcher, writer) to index. |
| [add()](#add) | Add \[document\]\[lupyne.engine.indexers.IndexWriter.document\] to index with optional boost. |
| [check()](#check) | Check and optionally fix unlocked index, returning lucene CheckIndex.Status. |
| [delete()](#delete) | Remove documents which match given query or term. |
| [document()](#document) | Return lucene Document from mapping of field names to one or multiple values. |
| [set()](#set) | Assign settings to field name and return the field. |
| [snapshot()](#snapshot) | Return context manager of an index commit snapshot. |
| [update()](#update) | Atomically delete documents which match given term |

------------------------------------------------------------------------


#### \_\_iadd\_\_()


Add directory (or reader, searcher, writer) to index.


Usage

``` python
__iadd__(directory)
```


------------------------------------------------------------------------


#### add()


Add \[document\]\[lupyne.engine.indexers.IndexWriter.document\] to index with optional boost.


Usage

``` python
add(document=(), **terms)
```


------------------------------------------------------------------------


#### check()


Check and optionally fix unlocked index, returning lucene CheckIndex.Status.


Usage

``` python
check(directory, repair=False)
```


------------------------------------------------------------------------


#### delete()


Remove documents which match given query or term.


Usage

``` python
delete(*query, **options)
```


\*query: \[search\]\[lupyne.engine.indexers.IndexSearcher.search\] compatible query, or optimally a name and value \*\*options: additional \[parse\]\[lupyne.engine.analyzers.Analyzer.parse\] options


------------------------------------------------------------------------


#### document()


Return lucene Document from mapping of field names to one or multiple values.


Usage

``` python
document(items=(), **terms)
```


------------------------------------------------------------------------


#### set()


Assign settings to field name and return the field.


Usage

``` python
set(name, cls=Field, **settings)
```


##### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| name |  | registered name of field | \- |
| cls |  | optional \[Field\]\[lupyne.engine.documents.Field\] constructor \*\*settings: stored, indexed, etc. options compatible with \[Field\]\[lupyne.engine.documents.Field\] | \- |

------------------------------------------------------------------------


#### snapshot()


Return context manager of an index commit snapshot.


Usage

``` python
snapshot()
```


------------------------------------------------------------------------


#### update()


Atomically delete documents which match given term


Usage

``` python
update(name, value="", document=(), **terms)
```


and add the new \[document\]\[lupyne.engine.indexers.IndexWriter.document\].
