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 read].freeze
DEFAULT_SORT_DIRECTION =
'asc'.freeze

Instance Method Summary collapse

Instance Method Details

#ascAttribute

Return attribute with direction set to ascending

Returns:



37
38
39
# File 'lib/rom/elasticsearch/attribute.rb', line 37

def asc
  meta(direction: 'asc')
end

#descAttribute

Return attribute with direction set to descending

Returns:



46
47
48
# File 'lib/rom/elasticsearch/attribute.rb', line 46

def desc
  meta(direction: 'desc')
end

#propertiesHash

Return ES mapping properties

Returns:

  • (Hash)


19
20
21
# File 'lib/rom/elasticsearch/attribute.rb', line 19

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)


28
29
30
# File 'lib/rom/elasticsearch/attribute.rb', line 28

def properties?
  properties.size > 0
end