Module: ElasticGraph::GraphQL::DatastoreQuery::RoutingValueSet::UnboundedWithExclusions

Defined in:
lib/elastic_graph/graphql/datastore_query/routing_picker.rb

Overview

This ‘RoutingValueSet` implementation is used for otherwise unrepresentable cases. We use it when a filter on one of the `routing_field_paths` uses an inequality like:

{routing_field: {gt: "abc"}}

In a case like that, the set is unbounded (there’s an infinite number of values that are greater than ‘“abc”`…), but it’s not ‘RoutingValueSet::ALL`–since it’s based on an inequality, there are some values that are excluded from the set. But we can’t use ‘RoutingValueSet.of_all_except(…)` because the set of exclusions is also unbounded!

When our filter value extraction results in this set, we must search all shards of the index and cannot pass any ‘routing` value to the datastore at all.

Class Method Summary collapse

Class Method Details

.intersection(other) ⇒ Object



197
198
199
200
201
202
203
204
# File 'lib/elastic_graph/graphql/datastore_query/routing_picker.rb', line 197

def self.intersection(other)
  # Technically, the "true" intersection would be `other - values_of(self)` but as we don't have
  # any known values from this unbounded set, we just return `other`. It's OK to include extra values
  # in the set (we'll search additional shards) but not OK to fail to include necessary values in
  # the set (we'd avoid searching a shard that may have matching documents) so we err on the side of
  # including more values.
  other
end

.negateObject



213
214
215
216
217
218
219
# File 'lib/elastic_graph/graphql/datastore_query/routing_picker.rb', line 213

def self.negate
  # This here is the only difference in behavior of this set implementation vs `RoutingValueSet::ALL`.
  # Where as `ALL.negate` returns an empty set, we treat `negate` as a no-op. We do that because the
  # negation of an inexact unbounded set is still an inexact unbounded set. While it flips which values
  # are in or out of the set, this object is still the representation in our datamodel for that case.
  self
end

.to_return_valueObject



221
222
223
224
225
# File 'lib/elastic_graph/graphql/datastore_query/routing_picker.rb', line 221

def self.to_return_value
  # Here we return `nil` to make sure that the datastore searches all shards, since we don't have
  # any information we can use to safely limit what shards it searches.
  nil
end

.union(other) ⇒ Object



206
207
208
209
210
211
# File 'lib/elastic_graph/graphql/datastore_query/routing_picker.rb', line 206

def self.union(other)
  # Since our set here is unbounded, the resulting union is also unbounded. This errs on the side
  # of safety since this set's `to_return_value` returns `nil` to cause the datastore to search
  # all shards.
  self
end