/usr/lib/ruby/vendor_ruby/chef_zero/solr/query/binary_operator.rb is in chef-zero 4.5.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | module ChefZero
module Solr
module Query
class BinaryOperator
def initialize(left, operator, right)
@left = left
@operator = operator
@right = right
end
def to_s
"(#{left} #{operator} #{right})"
end
attr_reader :left
attr_reader :operator
attr_reader :right
def matches_doc?(doc)
case @operator
when 'AND'
left.matches_doc?(doc) && right.matches_doc?(doc)
when 'OR'
left.matches_doc?(doc) || right.matches_doc?(doc)
when '^'
left.matches_doc?(doc)
when ':'
if left.respond_to?(:literal_string) && left.literal_string
values = doc[left.literal_string]
else
values = doc.matching_values { |key| left.matches_values?([key]) }
end
right.matches_values?(values)
end
end
def matches_values?(values)
case @operator
when 'AND'
left.matches_values?(values) && right.matches_values?(values)
when 'OR'
left.matches_values?(values) || right.matches_values?(values)
when '^'
left.matches_values?(values)
when ':'
raise ": does not work inside a : or term"
end
end
end
end
end
end
|