This directory contains the Rust-based C FFI wrapper for Tantivy, used by the Inko bindings.
cargo build --releaseThis will create target/release/libtantivy_c.dylib (macOS) or target/release/libtantivy_c.so (Linux).
Install the library to a system library directory:
macOS:
sudo cp target/release/libtantivy_c.dylib /usr/local/lib/Linux:
sudo cp target/release/libtantivy_c.so /usr/local/lib/
sudo ldconfig # Update library cacheSet the library search path before running Inko:
macOS:
export LIBRARY_PATH=/path/to/inko-tantivy/native/tantivy-c/target/release
export DYLD_LIBRARY_PATH=/path/to/inko-tantivy/native/tantivy-c/target/releaseLinux:
export LIBRARY_PATH=/path/to/inko-tantivy/native/tantivy-c/target/release
export LD_LIBRARY_PATH=/path/to/inko-tantivy/native/tantivy-c/target/releaseFrom the project root:
./build.sh test # Build and run tests automatically
./build.sh install # Install system-wide (requires sudo)The library exports the following functions for use from Inko:
tantivy_index_open- Open or create an indextantivy_index_close- Close an indextantivy_index_add_doc- Add a document to the indextantivy_index_delete_doc- Delete a documenttantivy_index_search- Search the indextantivy_index_commit- Commit pending changestantivy_index_rollback- Rollback pending changestantivy_index_get_doc- Get a document by IDtantivy_index_get_docs- Get multiple documents by IDtantivy_aggregate_terms- Aggregate document counts by field valuestantivy_get_facet_counts- Get facet counts for a fieldtantivy_autocomplete- Get autocomplete suggestionstantivy_did_you_mean- Get fuzzy spelling suggestions- Memory management functions for freeing allocated results
This means the linker can't find the library. Solutions:
- Install the library system-wide (see Option 1 above)
- Set LIBRARY_PATH environment variable (see Option 2 above)
- Use
make testwhich handles this automatically
If integration tests are skipped, it means the FFI library is not accessible. The tests check for FFI availability and gracefully skip if the library can't be loaded.
The tantivy_get_facet_counts function currently uses manual term aggregation rather than Tantivy's hierarchical Facet features. This is appropriate for the email search use case, where we're counting documents by simple string values (mailbox names, flags, labels, etc.) rather than hierarchical categories.
For true hierarchical faceting, you would need to:
- Define fields with the
FACEToption in the schema - Use Tantivy's
FacetCollectorin the implementation
The current implementation is optimized for the intended use case and provides good performance for flat faceting.