solr

corneliu edited this page Jul 23, 2013 · 6 revisions

Solr wrapper adaptor over solr-node-client

config

[...]
/**
 * Boot modules
 */
,boot : {        
    /**
     * solr configuration
     */
    , search : [
        'solr'
        , { host : '1.2.3.4', port : '8983' } //master
        , { host : '1.2.3.5', port : '8983' } //slave
        , 'somecore' //defaultcore
        , { slow : 5 } //log queries that take longer
    ]
[...]

fetch connection

this.kernel . search ( core : string, callback : function (err, connection) )

Accessing the link will return (via the callback) a solr connection.

search

conn . search ( query : query, function (err, results) )

var query = conn.query();
    query . q('test search');
    query . start(0);
    query . rows(50);

conn.search(query, function(err, results) {
    console.log(err, results);
}); 

add document

conn . add ( document : object, function (err) )

conn.add(
    { id : 1234, field_from_your_schema : 5, another_one : 'test' } ,
    function (err) {
        console.log(err);
    }
);

delete document

conn . delete ( id : number, function (err) )

conn.delete(id, function(err) { 
    console.log(err);
});