Class: ROM::Elasticsearch::Attribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/rom/elasticsearch/attribute.rb

Overview

ES-specific attribute types for schemas

Constant Summary collapse

INTERNAL_META_KEYS =
%i[name source primary_key].freeze
DEFAULT_SORT_DIRECTION =
'asc'.freeze

Instance Method Summary collapse

Instance Method Details

#ascAttribute

Return attribute with direction set to ascending

Returns:



35
36
37
# File 'lib/rom/elasticsearch/attribute.rb', line 35

def asc
  meta(direction: 'asc')
end

#descAttribute

Return attribute with direction set to descending

Returns:



44
45
46
# File 'lib/rom/elasticsearch/attribute.rb', line 44

def desc
  meta(direction: 'desc')
end

#propertiesHash

Return ES mapping properties

Returns:

  • (Hash)


17
18
19
# File 'lib/rom/elasticsearch/attribute.rb', line 17

memoize def properties
  type.meta.reject { |k, _| INTERNAL_META_KEYS.include?(k) }
end

#properties?Bool

Return if an attribute has any ES mappings

Returns:

  • (Bool)


26
27
28
# File 'lib/rom/elasticsearch/attribute.rb', line 26

def properties?
  properties.size > 0
end