Standardizes the Index::create_* APIs (#317)

* Pull all creation methods next to each other

The goal here is to make it clear which methods are performing the
same function, and to assist with standardizing the API calls.

* Make `from_directory` private

This seems to be an internal function, so lets make it internal.

* Rename `create` to `create_in_dir`

This lets the name match the `create_in_ram` pattern and opens up
`create` for the generic implementation.

* Implement the generic create function

All of the create methods now delegate to the common create function
and future `create_in_*` functions now have a clear pattern
to follow as well
This commit is contained in:
Dru Sellers
2018-06-13 21:08:42 -05:00
committed by Paul Masurel
parent 0465876854
commit 2b8f02764b
4 changed files with 24 additions and 25 deletions

View File

@@ -61,7 +61,7 @@ fn run_example(index_path: &Path) -> tantivy::Result<()> {
//
// This will actually just save a meta.json
// with our schema in the directory.
let index = Index::create(index_path, schema.clone())?;
let index = Index::create_in_dir(index_path, schema.clone())?;
// here we are registering our custome tokenizer
// this will store tokens of 3 characters each

View File

@@ -64,7 +64,7 @@ fn run_example(index_path: &Path) -> tantivy::Result<()> {
//
// This will actually just save a meta.json
// with our schema in the directory.
let index = Index::create(index_path, schema.clone())?;
let index = Index::create_in_dir(index_path, schema.clone())?;
// To insert document we need an index writer.
// There must be only one writer at a time.