GitXplorerGitXplorer
g

node-solr

public
222 stars
39 forks
1 issues

Commits

List of commits on branch master.
Unverified
caceea9a4daea69cd199a074769b22399bd89104

Added param test case

ppabloviquez committed 10 years ago
Unverified
04fc61e80ef1ae7d173ea05e89bedb7a2067202e

Added README.md

ppabloviquez committed 10 years ago
Unverified
f3f437e66b805ae911fdb283355127d411e30f56

Added README.md

ppabloviquez committed 10 years ago
Unverified
14bb8edc55b464114cae4cae751e4fb886b51548

Fixing value parameter

ppabloviquez committed 10 years ago
Unverified
4a1d8fe12e743493ed5257495943e431c8e255a0

Fixing concatenation of parameters

ppabloviquez committed 10 years ago
Unverified
775f2b9498b2ea1d32e7b4da6a106fa25f7bb222

Fixing comparison error

ppabloviquez committed 10 years ago

README

The README file for this repository.

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'
};