Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Solr module for Node.js
JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
LICENSE
README
package.json
solr.js

README

Solr module for Node.js


Node.js: http://github.com/ry/node
Solr: http://lucene.apache.org/solr/

For testing, node-solr depends on node-async-testing, found at 
http://github.com/bentomas/node-async-testing. Run all tests with 
"node test/all.js". You need to have Solr running at 127.0.0.1:8983.
Be aware that some tests are failing occasionally due to async 
issues in the test suite.

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

    var solr = require("solr");
    var sys = require("sys");

    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"
    };
    var callback = function (err, response) {
      if (err) {
        throw err;
      }
      sys.puts("Document added");
    };
    client.add(doc1, callback);
    client.add(doc2, callback);
    client.commit();

    var query = "text_t:fizz"
    callback = function (err, response) {
      var responseObj = JSON.parse(response);
      sys.puts("A search for \"" + query + "\" returned " + 
          responseObj.response.numFound + " documents.");
      sys.puts("First doc title: " + responseObj.response.docs[0].title_t);
      sys.puts("Second doc title: " + responseObj.response.docs[1].title_t);
    };
    client.query(query, callback);

    var id;
    callback = function (err, response) {
      sys.puts("Deleted all docs matching query \"" + query + "\"");
    };
    client.del(id, query, callback);
    client.commit();

Something went wrong with that request. Please try again.