tantivy icon indicating copy to clipboard operation
tantivy copied to clipboard

Node bindings

Open Frando opened this issue 6 years ago • 5 comments

I started to work on node bindings for tantivy:

tantivy-node

Very basic still, but works. I'm new to rust and writing bindings, so if anyone wants to follow along or chime in feel free to!

Frando avatar Jan 21 '19 13:01 Frando

First of all that's awesome! Thank you for driving that effort.

A couple of comment. It is a bad idea to commit after adding each document. Inserts are meant to be batched.

You shouldn't create and drop the IndexWriter everything time. On drop, you non-commited documents are lost.

I suggest either mimicking tantivy's API, or adding a IndexWriter field to your JsIndex.

One problem with this approach is that you will only be able to create one processor reading the index at the same time. Maybe you could make that IndexWriter and Option<IndexWriter>, only populate it, when the index is opened as writable, and throw everytime someone tries to add a doc or delete a term on a readonly segment.

fulmicoton avatar Jan 21 '19 23:01 fulmicoton

@Frando also, do you need help for this?

fulmicoton avatar Jan 25 '19 00:01 fulmicoton

Thanks for the feedback!

I'm using this as a rust learning excercise for now. I reworked the whole project to use https://github.com/cztomsik/napi-rs in place of neon. Seems much leaner to work with, and neon does still not support n-api.

Pushed my changes to https://github.com/Frando/tantivy-node, still very basic (needs some high-level js wrapping also, but that's easy to do).

Frando avatar Jan 26 '19 22:01 Frando

I added another commit. Now has a test and a proper JS api. Still quite basic, but should be usable.

Biggest "bug" at the moment is that the IndexWriter lock is not cleared. The lock is cleared when the IndexWriter is dropped, right? If so I'd guess that the napi-rs bindings don't properly implement the finalizecallback from n-apiwhich could lead to the IndexWriter never being properly dropped - but I'm not sure.

Frando avatar Feb 19 '19 22:02 Frando

Is there any usable node bindings now? It's super awesome if tantivy can be used with Node.js

yf-hk avatar Jun 03 '21 10:06 yf-hk