class SearchIngest::Schemas

Defined in:

search-ingest/schemas.cr

Constant Summary

MODEL_METADATA = {} of Nil => Nil

Extracted metadata from ORM classes

MODELS = {} of Nil => Nil

All PgORM models with abstract and empty classes removed :nodoc:

TYPE_FIELD = Field.new("_document_type", "keyword")

Allows several document types beneath a single index

Constructors

Class Method Summary

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(models : Array(Class) = MANAGED_TABLES) #

[View source]

Class Method Detail

def self.document_name(model : Class | String) #

Strips the namespace from the model


[View source]
def self.equivalent_schema?(existing_schema : String | Nil, proposed_schema : String | Nil) : Bool #

Traverse schemas and test equality

ameba:disable Metrics/CyclomaticComplexity


[View source]

Instance Method Detail

def children(model : Class | String) #

Get names of all children associated with model


[View source]
def collect_index_properties(model : String | Class, children : Array(String) | Nil = nil) : Array(Field) #

Collects all properties relevant to an index and collapse them into a schema


[View source]
def construct_document_schema(model) : String #

Generate the index type mapping structure


[View source]
def generate_index_properties(model, child = false) : Array(Field) #

Now that we are generating joins on the parent_id, we need to specify if we are generating a child or a single document Maps from crystal types to Elasticsearch field datatypes


[View source]
def generate_properties(models) #

Construct properties for given models


[View source]
def generate_schemas(models) #

Generate a map of models to schemas


[View source]
def index_name(model) : String #

Look up index name by class


[View source]
def index_schema(model : Class | String) : String #

Look up model schema by class


[View source]
def index_schemas(klass : Class | String) #

[View source]
def index_schemas : Hash(String, String) #

Map from class name to schema


[View source]
def join_field(model, children) #

Generate join fields for parent relations


[View source]
def models : Array(String) #

Class names of managed tables


[View source]
def parents(model : Class | String) : Array(Parent) #

Find name and ES routing of document's parents


[View source]
def properties(klass : Class | String) #

[View source]
def properties : Hash(String, Array(Field)) #

Map class name to model properties


[View source]
def validate_tag(tag) #

[View source]

Macro Detail

macro __create_model_metadata #

[View source]