Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
9flats
var value = 1;
var c = days.length;
for (var i = 0; i < c; i++) {
var v = _source.minimum_stays[days[i]];
if (v && value < v) {
value = v;
}
}
if (value == 1) {
value = _source.minimum_nights
}
c >= value;
# days.map do |date|
# {
# or: [
# {
# and: [
# {
# and: days.map do |d|
# {
# bool: {
# must: {
# not: {
# exists: {
# field: "minimum_stays.#{d}"
# }
# }
# }
# }
# }
# end
# },
# {
# bool: {
# must: {
# range: {
# minimum_nights: {
# lte: days.size
# }
# }
# }
# }
# }
# ]
# },
# {
# and: [
# {
# bool: {
# must: {
# exists: {
# field: "minimum_stays.#{date}"
# }
# }
# }
# },
# {
# bool: {
# must: {
# range: {
# "minimum_stays.#{date}" => {
# lte: days.size
# }
# }
# }
# }
# }
# ]
# },
# {
# and: [
# {
# or: days.map do |d|
# {
# bool: {
# must: {
# exists: {
# field: "minimum_stays.#{d}"
# }
# }
# }
# }
# end
# },
# bool: {
# must: {
# not: {
# exists: {
# field: "minimum_stays.#{date}"
# }
# }
# }
# }
# ],
# },
# ]
# }
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.