[Xapian-discuss] Node.js binding

Liam xapian at networkimprov.net
Fri Oct 28 20:29:28 BST 2011


On Tue, Oct 25, 2011 at 10:52 AM, Liam <xapian at networkimprov.net> wrote:

> Hoping someone can point me to a v1.2 index I can download to test my Node
> binding against...
>

Now working on indexing in the Node binding...

I plan to provide a high-level indexing API which takes a collection of
document parameters, rather than surface Xapian's intricate API for
constructing documents, as most of those calls could do I/O, and doing piles
of async calls isn't efficient or pleasant to code.

My reference point is the omindex code, which uses...
  data: list of name=value
  indexed text: title, body, keywords, file-name, author
  boolean terms: mimetype, site, host, date, month, year, url, group, owner,
file-ext
  values: mod_time, md5, size

I imagine a document parameters object like:
  var doc_input = {
    oid: string, // boolean term; if found in index, replace that document
    data: string, // pass to set_data()
    text: { field: string/buffer, ... }, // pass to index_text()
    files: [ pathname, ... ], // invoke format converter library, then
index_text()
    terms: { term: wdfinc, ... }, // pass to add_term()
    values: { slot: value, ... } // pass to add_value()
  }
All the members are optional, but at least one is required. Providing oid
with nothing else removes that document.

The API looks like:

var db = new WritableDatabase(...);
var tg = new TermGenerator(...);
db.insert_document(tg, doc_input, doc_id); // if doc_id != undefined,
replace/delete doc
 // doc_id has precedence over doc_input.oid

Thoughts?


More information about the Xapian-discuss mailing list