pelias-query
Advanced tools
Comparing version 9.19.0 to 9.19.1
@@ -17,3 +17,3 @@ module.exports = function( property, value, params ) { | ||
optional_params.forEach(function(param) { | ||
if (params && params[param]) { | ||
if (params && params[param] && params[param].toString() !== '') { | ||
query.match_phrase[property][param] = params[param]; | ||
@@ -20,0 +20,0 @@ } |
@@ -28,3 +28,3 @@ const optional_params = [ | ||
optional_params.forEach(function(param) { | ||
if (params && params[param]) { | ||
if (params && params[param] && params[param].toString() !== '') { | ||
query.match[property][param] = params[param]; | ||
@@ -31,0 +31,0 @@ } |
{ | ||
"name": "pelias-query", | ||
"version": "9.19.0", | ||
"version": "9.19.1", | ||
"description": "An Elasticsearch query builder for Pelias", | ||
@@ -5,0 +5,0 @@ "engines": { |
const match_phrase = require('../../../lib/leaf/match_phrase'); | ||
const Variable = require('../../../lib/Variable'); | ||
@@ -82,2 +83,32 @@ module.exports.tests = {}; | ||
}); | ||
test('match_phrase query does not allow empty string as optional param value', function(t) { | ||
const query = match_phrase('property', 'value', { slop: '' }); | ||
const expected = { | ||
match_phrase: { | ||
property: { | ||
query: 'value' | ||
} | ||
} | ||
}; | ||
t.deepEqual(query, expected, 'valid match_phrase query without empty string value'); | ||
t.end(); | ||
}); | ||
test('match_phrase query does not allow empty Variable as optional param value', function(t) { | ||
const query = match_phrase('property', 'value', { analyzer: new Variable() }); | ||
const expected = { | ||
match_phrase: { | ||
property: { | ||
query: 'value' | ||
} | ||
} | ||
}; | ||
t.deepEqual(query, expected, 'valid match_phrase query with out empty string value'); | ||
t.end(); | ||
}); | ||
}; | ||
@@ -84,0 +115,0 @@ |
const match = require('../../../lib/leaf/match'); | ||
const Variable = require('../../../lib/Variable'); | ||
@@ -130,2 +131,32 @@ module.exports.tests = {}; | ||
}); | ||
test('match query does not allow empty string as optional param value', function(t) { | ||
const query = match('property', 'value', { analyzer: ''}); | ||
const expected = { | ||
match: { | ||
property: { | ||
query: 'value' | ||
} | ||
} | ||
}; | ||
t.deepEqual(query, expected, 'valid match query with out empty string value'); | ||
t.end(); | ||
}); | ||
test('match query does not allow empty Variable as optional param value', function(t) { | ||
const query = match('property', 'value', { analyzer: new Variable() }); | ||
const expected = { | ||
match: { | ||
property: { | ||
query: 'value' | ||
} | ||
} | ||
}; | ||
t.deepEqual(query, expected, 'valid match query with out empty string value'); | ||
t.end(); | ||
}); | ||
}; | ||
@@ -132,0 +163,0 @@ |
315417
9652
1