Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full text search not working #69

Closed
xianlin opened this issue Apr 30, 2015 · 1 comment
Closed

full text search not working #69

xianlin opened this issue Apr 30, 2015 · 1 comment

Comments

@xianlin
Copy link

xianlin commented Apr 30, 2015

after git clone and npm install and node ./bin/index.js, the full text search is not working.

db.json using:

{
  "posts": [
    {
      "id": 1,
      "title": "json-server",
      "author": "typicode"
    }
  ],
  "comments": [
    {
      "id": 1,
      "body": "some comment",
      "postId": 1
    }
  ]
}

Query using:

GET http://localhost:3000/post?q=json-server

It appears that the below code didn't run into the array = db().filter() and for loop is not running at all:

if (req.query.q) {

      // Full-text search
      var q = req.query.q.toLowerCase()
      array = db(req.params.resource).filter(function(obj) {
        for (var key in obj) {
          var value = obj[key]
          if (_.isString(value) && value.toLowerCase().indexOf(q) !== -1) {
            return true
          }
        }
      })

    } else {

Can anyone tell me how to get full text search working?

@xianlin xianlin closed this as completed Apr 30, 2015
@xianlin
Copy link
Author

xianlin commented Apr 30, 2015

wrong url used... close the issue for good..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant