Browse Source

Change query to use `terms` and add code coverage stats

pull/115/head
Diana Shkolnikov 10 years ago
parent
commit
7b5a2fafb9
  1. 2
      .gitignore
  2. 1
      .jshintignore
  3. 7
      .travis.yml
  4. 4
      README.md
  5. 4
      package.json
  6. 12
      query/reverse.js
  7. 13
      test/unit/query/reverse.js

2
.gitignore vendored

@ -1,2 +1,4 @@
node_modules
coverage
.idea
*.log

1
.jshintignore

@ -1 +1,2 @@
node_modules
coverage

7
.travis.yml

@ -1,4 +1,9 @@
language: node_js
script: "npm run unit"
node_js:
- "0.10"
- "0.10"
addons:
code_climate:
repo_token: a98bd9004512c8caf44e5cb2b3586d01baf190ee069ec0b731b451fc9966e639
after_script:
- codeclimate < coverage/lcov.info

4
README.md

@ -1,6 +1,10 @@
# API
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/pelias/api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Code Climate](https://codeclimate.com/github/pelias/api/badges/gpa.svg)](https://codeclimate.com/github/pelias/api)
[![Test Coverage](https://codeclimate.com/github/pelias/api/badges/coverage.svg)](https://codeclimate.com/github/pelias/api)
Pelias RESTful API
## Documentation

4
package.json

@ -8,9 +8,10 @@
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "npm run unit",
"test": "npm run unit && npm run coverage",
"unit": "node test/unit/run.js | tap-spec",
"ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao",
"coverage": "node_modules/.bin/istanbul cover test/unit/run.js",
"audit": "npm shrinkwrap; node node_modules/nsp/bin/nspCLI.js audit-shrinkwrap; rm npm-shrinkwrap.json;",
"docs": "rm -r docs; cd test/ciao; node ../../node_modules/ciao/bin/ciao -c ../ciao.json . -d ../../docs"
},
@ -44,6 +45,7 @@
},
"devDependencies": {
"ciao": "^0.3.4",
"istanbul": "^0.3.13",
"jshint": "^2.5.6",
"nsp": "^0.3.0",
"precommit-hook": "^1.0.7",

12
query/reverse.js

@ -20,15 +20,9 @@ function generate( params ){
}
function addCategoriesFilter( query, categories ) {
query.query.filtered.query = {
match: {
category: {
query: categories.join(' '),
analyzer: 'standard',
operator: 'or'
}
}
};
query.query.filtered.filter.bool.must.push({
terms: { category: categories }
});
}
module.exports = generate;

13
test/unit/query/reverse.js

@ -120,13 +120,7 @@ module.exports.tests.query = function(test, common) {
'query': {
'filtered': {
'query': {
'match': {
'category': {
'query': 'food education entertainment',
'analyzer': 'standard',
'operator': 'or'
}
}
'match_all': {}
},
'filter': {
'bool': {
@ -142,6 +136,11 @@ module.exports.tests.query = function(test, common) {
'lon': '-82.51'
}
}
},
{
'terms': {
'category': params.categories
}
}
]
}

Loading…
Cancel
Save