pouchdb-community/pouchdb-quick-search

Search only returns results for certain words

Open

#38 opened on Oct 23, 2015

View on GitHub
 (5 comments) (2 reactions) (0 assignees)JavaScript (82 forks)github user discovery
help wanted

Repository metrics

Stars
 (377 stars)
PR merge metrics
 (PR metrics pending)

Description

Somehow I cannot get search to find anything except if the query is work or pattern. Other terms like computer, lion and dog do not return any results. Test code is below. None of these terms are stopwords, so I don't understand why no results are found.

var assert = require('assert');
var uuid = require('node-uuid');
var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-quick-search'));

var text = 'lion';

var db = new PouchDB('test-db');
var obj = {
  _id: uuid.v4(),
  text: text
};

function build(cb) {
  cb();
}

db.put(obj, function (err, res) {
  if (err) console.log(err, res);
  db.get(obj._id, function (err, o) {
    assert(!err && o._id === obj._id);

    var options = {
      query: text,
      fields: ['text'],
    };

    db.search(options, function (err, result) {
      assert(!err);
      assert(result.total_rows > 0);

      build(function (err) {
        assert(!err);

        db.search(options, function (err, result) {
          assert(!err);
          assert(result.total_rows > 0);
        });
      });
    });
  });
});

Contributor guide