123456789_123456789_123456789_123456789_123456789_

Class: Redis::Commands::Search::GeoShapeField

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Field
Instance Chain:
self, Field
Inherits: Redis::Commands::Search::Field
Defined in: lib/redis/commands/modules/search/field.rb

Overview

A GEOSHAPE field, indexing geometric shapes under a coordinate system.

Constant Summary

Class Method Summary

Field - Inherited

.new

Build a field definition.

Instance Attribute Summary

Instance Method Summary

Field - Inherited

#to_args

Render this field as the array of FT.CREATE SCHEMA tokens.

Constructor Details

.new(name, coord_system = nil, **options) ⇒ GeoShapeField

Build a GEOSHAPE field.

Parameters:

  • name (String, Symbol)

    the document attribute the field indexes

  • coord_system (String, nil) (defaults to: nil)

    the coordinate system, FLAT or SPHERICAL; nil (the default) omits the token so the server default (SPHERICAL) applies

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :no_index (Boolean)

    do not index the field (+NOINDEX+)

  • :index_missing (Boolean)

    index documents missing the field (+INDEXMISSING+)

  • :sortable (Boolean)

    allow sorting by the field (+SORTABLE+)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/field.rb', line 203

def initialize(name, coord_system = nil, **options)
  super(name, :geoshape, nil, **options)
  @coord_system = coord_system
end

Instance Method Details

#to_argsArray

Render this field as the array of FT.CREATE SCHEMA tokens.

Returns:

  • (Array)

    the schema tokens for this field

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/field.rb', line 211

def to_args
  args = [@name]
  args << "AS" << @alias_name if @alias_name
  args << @type.to_s.upcase
  args << @coord_system if @coord_system

  # Add suffix options (order mirrors the base Field: NOINDEX, INDEXMISSING, SORTABLE).
  # GEOSHAPE supports INDEXMISSING but not INDEXEMPTY/WITHSUFFIXTRIE.
  args << "NOINDEX" if @options[:no_index]
  args << "INDEXMISSING" if @options[:index_missing]
  args << "SORTABLE" if @options[:sortable]

  args
end