class Druid::Query

Attributes

aggregations[RW]
bound[RW]

timeBoundary

context[RW]
dataSource[RW]
dimension[RW]

topN

dimensions[RW]
filter[RW]
granularity[RW]
having[RW]

groupBy

intervals[RW]
limit[RW]

search

limitSpec[RW]

groupBy

merge[RW]

segementMetadata

metric[RW]

topN

metrics[RW]

select

pagingSpec[RW]

select

postAggregations[RW]
query[RW]

search

queryType[RW]
searchDimensions[RW]

search

sort[RW]

search

threshold[RW]

topN

toInclude[RW]

segementMetadata

Public Class Methods

new(attributes = {}) click to toggle source
Calls superclass method
# File lib/druid/query.rb, line 288
def initialize(attributes = {})
  super
  @context ||= Context.new
end

Public Instance Methods

aggregation_names() click to toggle source
# File lib/druid/query.rb, line 164
def aggregation_names
  Set.new(@aggregations.map do |aggregation|
    [aggregation.fieldName] + [aggregation.fieldNames]
  end.flatten.compact)
end
aggregation_types() click to toggle source
# File lib/druid/query.rb, line 158
def aggregation_types
  Set.new(@aggregations.map do |aggregation|
    aggregation.type
  end.flatten.compact)
end
aggregations=(value) click to toggle source
# File lib/druid/query.rb, line 146
def aggregations=(value)
  if value.is_a?(Array)
    @aggregations = value.map do |x|
      x.is_a?(Aggregation) ? x : Aggregation.new(x)
    end
  else
    @aggregations = [
      value.is_a?(Aggregation) ? value : Aggregation.new(value)
    ]
  end
end
as_json(options = {}) click to toggle source
Calls superclass method
# File lib/druid/query.rb, line 293
def as_json(options = {})
  super(options.merge(except: %w(errors validation_context)))
end
contains_aggregation?(metric) click to toggle source
# File lib/druid/query.rb, line 297
def contains_aggregation?(metric)
  aggregations.any? { |a| a.name.to_s == metric.to_s }
end
context=(value) click to toggle source
# File lib/druid/query.rb, line 280
def context=(value)
  if value.is_a?(Hash)
    @context = Context.new(value)
  else
    @context = value
  end
end
dimensions=(value) click to toggle source
# File lib/druid/query.rb, line 107
def dimensions=(value)
  if value.is_a?(Array)
    @dimensions = value.map do |x|
      x.is_a?(Dimension) ? x : Dimension.new(x)
    end
  else
    @dimensions = [
      value.is_a?(Dimension) ? value : Dimension.new(value)
    ]
  end
end
filter=(value) click to toggle source
# File lib/druid/query.rb, line 220
def filter=(value)
  if value.is_a?(Hash)
    @filter = Filter.new(value)
  else
    @filter = value
  end
end
granularity=(value) click to toggle source
# File lib/druid/query.rb, line 70
def granularity=(value)
  if value.is_a?(String)
    @granularity = value
  elsif value.is_a?(Hash)
    @granularity = Granularity.new(value)
  else
    @granularity = value
  end
end
having=(value) click to toggle source
# File lib/druid/query.rb, line 231
def having=(value)
  if value.is_a?(Hash)
    @having = Having.new(value)
  else
    @having = value
  end
end
postAggregations=(value) click to toggle source
# File lib/druid/query.rb, line 193
def postAggregations=(value)
  if value.is_a?(Array)
    @postAggregations = value.map do |x|
      PostAggregation.new(x)
    end
  else
    @postAggregations = [value]
  end
end