[Xapian-discuss] Node.js binding

Liam xapian at networkimprov.net
Sun Oct 23 20:07:52 BST 2011

On Sun, Oct 23, 2011 at 11:50 AM, James Aylett <james-xapian at tartarus.org>wrote:

> On 21 Oct 2011, at 15:59, Liam wrote:
> > For Enquire::get_mset(callback), the callback will return an array of
> > objects (which include a Document):
> >  { id: string,
> >    rank: number,
> >    weight: number,
> >    collapse_key: string,
> >    collapse_count: number,
> >    percent: number,
> >    description: string,
> >    document: object // Document
> >  }
> >
> > Sound reasonable?
> You almost certainly don't need percent; most people never have a use for
> this. Also, if you're not giving parameters to `get_mset` then you want  to
> return something lazy rather than an array, something more like a generator
> (I don't know what's available to you in V8 & Node). Xapian matches are
> explicitly paged (so you pull an MSet for a number of entries from a
> specific offset). Using a generator approach you can implement the paging
> below the level of the application (perhaps with initial hints), similar to
> how many ORMs work for LIMIT paging in SQL.

Can you explain further? Sample code?

Each async call requires a trip through the thread pool (that's the only way
to make blocking code appear non-blocking) which is not terribly efficient,
and requires more glue code than it ought. So I think you'd always return a
group of matches. Is it possible to know the number of entries per page? It
might make sense to limit the array to a single page...

Mating Node with a traditional synchronous API typically involves some
reinterpretation, and possibly many interpretations for different contexts.

More information about the Xapian-discuss mailing list