Module: Eaco::Adapters::CouchrestModel::CouchDBLucene
- Defined in:
- lib/eaco/adapters/couchrest_model/couchdb_lucene.rb
Overview
Authorized collection extractor on CouchDB using the CouchDB Lucene full-text indexer <github.com/ifad/couchdb-lucene>, a patched CouchRest <github.com/ifad/couchrest> to interact with the “_fti” couchdb lucene API endpoint, and a patched CouchRest::Model <github.com/ifad/couchrest_model> that provides a search() API to run lucene queries.
It requires an indexing strategy similar to the following:
{
_id: "_design/lucene",
language: "javascript",
fulltext: {
search: {
defaults: { store: "no" },
analyzer: "perfield:{acl:\"keyword\"}",
index: function(doc) {
var acl = doc.acl;
if (!acl) {
return null;
}
var ret = new Document();
for (key in acl) {
ret.add(key, {
type: 'string',
field: 'acl',
index: 'not_analyzed'
});
}
return ret;
}
}
}
}
Made in Italy.
:nocov: because there are too many moving parts here and anyway we are going to deprecate this in favour of jsonb
Instance Method Summary collapse
-
#accessible_by(actor) ⇒ CouchRest::Model::Search::View
Uses a Lucene query to extract Resources accessible by the given Actor.
Instance Method Details
#accessible_by(actor) ⇒ CouchRest::Model::Search::View
Uses a Lucene query to extract Resources accessible by the given Actor.
62 63 64 65 66 67 68 |
# File 'lib/eaco/adapters/couchrest_model/couchdb_lucene.rb', line 62 def accessible_by(actor) return search(nil) if actor.is_admin? designators = actor.designators.map {|item| '"%s"' % item } search "acl:(#{designators.join(' OR ')})" end |