Skip to content
Solr module for Node.js
JavaScript
Latest commit c36dc6b Jun 5, 2015 @pabloviquez pabloviquez Merge pull request #25 from pabloviquez/master
New method on client
Failed to load latest commit information.
lib Adding admin call reload to client Jun 5, 2015
test Added param test case Apr 24, 2015
LICENSE Include current year in copyright Mar 14, 2011
README Added support for parameters in fields. Apr 24, 2015
README.md
index.js Moved solr.js to lib/ and updated package.json Jan 24, 2011
package.json

README.md

Solr module for Node.js

References

Run tests with npm test. Edit "test/common.js" if you don't have Solr running at 127.0.0.1:8983.

Usage Example

See tests for usage. Here's a quick example:

    var solr = require('solr');

    var client = solr.createClient();
    var doc1 = {
      id: '1',
      title_t: 'Foo bar',
      text_t: 'Fizz buzz frizzle'
    };
    var doc2 = {
      id: '2',
      title_t: 'Far boo',
      text_t: 'Wuzz fizz drizzle'
    };

    client.add(doc1, function(err) {
      if (err) throw err;
      console.log('First document added');
      client.add(doc2, function(err) {
        if (err) throw err;
        console.log('Second document added');
        client.commit(function(err) {
          var query = 'text_t:fizz'
          client.query(query, function(err, response) {
            if (err) throw err;
            var responseObj = JSON.parse(response);
            console.log('A search for "' + query + '" returned ' +
                responseObj.response.numFound + ' documents.');
            console.log('First doc title: ' + 
                responseObj.response.docs[0].title_t);
            console.log('Second doc title: ' + 
                responseObj.response.docs[1].title_t);
            client.del(null, query, function(err, response) {
              if (err) throw err;
              console.log('Deleted all docs matching query "' + query + '"');
              client.commit()
            });
          });
        });
      });
    });

Optional Parameters

Solr add/replace documents supports optional parameters.

var doc1 = {
  id: '1',
  title_t: {
    params: {
      boost: '2.0'
    },
    value: 'Foo bar',
  },
  text_t: 'Fizz buzz frizzle'
};
Something went wrong with that request. Please try again.