Socket
Socket
Sign inDemoInstall

backbone-db-elasticsearch

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-db-elasticsearch - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

5

index.js

@@ -38,3 +38,6 @@ var _ = require('lodash');

});
return results;
// sort by score
return _.sortBy(results, function(r) {
return -1 * r.score;
});
};

@@ -41,0 +44,0 @@

4

package.json
{
"name": "backbone-db-elasticsearch",
"version": "0.1.2",
"version": "0.1.3",
"description": "Elasticsearch driver for backbone-db",

@@ -29,3 +29,3 @@ "main": "index.js",

"debug": "~0.8",
"elasticsearch": "~2.1"
"elasticsearch": "~2.2"
},

@@ -32,0 +32,0 @@ "devDependencies": {

@@ -29,2 +29,3 @@ var setup = require('./setup');

name: 'abc',
tags: ['a', 'b'],
meta: {

@@ -47,2 +48,3 @@ score: 23

name: 'abc',
tags: ['c', 'b'],
meta: {

@@ -184,2 +186,25 @@ score: 40

it('should apply script score', function() {
var query = {
function_score: {
query: {
matchAll: {
}
},
script_score: {
script: "_source.tags.contains(\"c\") ? 100 : 0",
},
boost_mode: 'replace'
}
};
collection = new this.Collection();
return collection
.fetch({
query: query
})
.then(function() {
collection.at(0).get('content').title.should.equal('hop hep');
});
});
it('should sort', function() {

@@ -233,3 +258,37 @@ var query = {

});
it('should do msearch /w function_score', function() {
var queriesBody = [
// match all query
{ index: 'anotheridx'},
{ query: { match_all: {} } },
// query_string query, on index/type
{ index: 'testidx', type: 'test' },
{
query: {
function_score: {
query: {
matchAll: {
}
},
script_score: {
script: "_source.tags.contains(\"c\") ? 100 : 5",
},
boost_mode: 'replace'
}
}
}
];
collection = new this.Collection();
return collection
.fetch({
msearch: true,
body: queriesBody
})
.then(function() {
collection.length.should.equal(3);
collection.at(0).get('content').title.should.equal('hop hep');
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc