Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parent.results.forEach(parentResult => {
// support dotted fields
const [root, ...nested] = fieldStorage.split('.');
const value = dot.pick(root, parentResult);
if (!value) {
return;
}
const data = [];
value.forEach(v => {
const _id = nested.length > 0 ? dot.pick(nested.join('.'), v) : v;
data.push(_.first(resultsByKeyId[_id]));
});
parentResult[childCollectionNode.linkName] = filterAssembledData(
data,
{ limit, skip }
);
});
function addExistenceFilters(req, missingFilters, existsFilters){
// see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html
// and https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html
// is this a filtered query, or a regulat?
var boolFilter = dot.pick('body.query.filtered', req);
var getPreviousFilters = function(){
var andFilters;
if(boolFilter){
andFilters = dot.pick('body.query.filtered.query.constant_score.filter.and', req);
}else{
andFilters = dot.pick('body.query.constant_score.filter.and', req);
}
return andFilters || [];
};
var query = {
constant_score: {
filter: {
and: getPreviousFilters()
}
return f;
};
filter.bool.must = _.map(mustFilters, makeTermFilter);
filter.bool.must_not = _.map(notFilters, makeTermFilter);
// Remove any empty filters, Elasticsearch will throw an error.
_.each(filter.bool, function(v, k) {
if(!v || !v.length) delete filter.bool[k];
});
// No filters found? return now.
if(_.isEmpty(filter.bool)) return void 0;
// Is this a new filtered query, or an existing to merge with?
var boolFilter = dot.pick('body.query.filtered.filter.bool', req);
var mergeFilter = function(filterName, data){
if( _.isArray(boolFilter[filterName]) ){
req.body.query.filtered.filter.bool[filterName] = req.body.query.filtered.filter.bool[filterName].concat(data);
}else if( _.isPlainObject(boolFilter[filterName]) ){
req.body.query.filtered.filter.bool[filterName] = [boolFilter[filterName]];
req.body.query.filtered.filter.bool[filterName] = req.body.query.filtered.filter.bool[filterName].concat(data);
}else{
req.body.query.filtered.filter.bool[filterName] = data;
}
};
if(boolFilter){
if(filter.bool.must) mergeFilter('must', filter.bool.must);
if(filter.bool.must_not) mergeFilter('must_not', filter.bool.must_not);
}else{
requiredIfNot: function(def, value, key, errors, data) {
const type = 'requiredIfNot'
const sub = def.requiredIfNot
if (typeof sub === 'object') {
const field = Object.keys(sub)[0]
const fieldArr = Array.isArray(sub[field]) ? sub[field] : [ sub[field] ]
fieldArr.some(val => {
/* istanbul ignore else */
if (dot.pick(field, data) !== val && value === undefined) {
errors.push({ type, sub, key, value, message: `Value required because '${field}' value is not one specified` })
return true
}
})
} else if (dot.pick(sub, data) === undefined && value === undefined) {
errors.push({ type, sub, key, value, message: `Value required because '${sub}' is undefined`})
}
},
/**
read(key) {
let k = parseKey(key);
return dot.pick(k, cache);
}
has(path) {
return typeof dot.pick(path, this._config) !== 'undefined';
}
_id => !_.contains(_ids, nested.length > 0 ? dot.pick(nested.join('.'), _id) : _id)
);
var getPreviousFilters = function(){
var andFilters;
if(boolFilter){
andFilters = dot.pick('body.query.filtered.query.constant_score.filter.and', req);
}else{
andFilters = dot.pick('body.query.constant_score.filter.and', req);
}
return andFilters || [];
};
getValue () {
return this.context.doc ? DotObject.pick(this.getFieldName(), this.context.doc) : undefined
}
render () {
const value = dot.pick(this.props.field, this.props.data) || "";
return (
<div>
<label>{this.props.label}</label>
<input value="{value}" placeholder="{this.props.placeholder}" type="text" id="{this.id}">
</div>
);
}
}