class SearchIngest::Elastic

Included Modules

Defined in:

search-ingest/elastic.cr

Constant Summary

HABITAT_SETTINGS = [{decl: uri : URI | ::Nil = ES_URI, example: nil, validation: nil}, {decl: host : String = ES_HOST, example: nil, validation: nil}, {decl: port : Int32 = ES_PORT, example: nil, validation: nil}, {decl: tls : Bool = ES_TLS, example: nil, validation: nil}, {decl: pool_size : Int32 = ES_CONN_POOL || SearchIngest::MANAGED_TABLES.size, example: nil, validation: nil}, {decl: idle_pool_size : Int32 = ES_IDLE_POOL || (SearchIngest::MANAGED_TABLES.size // 4), example: nil, validation: nil}, {decl: pool_timeout : Float64 = ES_CONN_POOL_TIMEOUT, example: nil, validation: nil}] of Nil
Log = ::Log.for(self)

Constructors

Class Method Summary

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(host : String = settings.host, port : Int32 = settings.port, tls : Bool = settings.tls, uri : URI | Nil = settings.uri) #

[View source]

Class Method Detail

def self.apply_index_mapping(index, mapping) #

Applies a mapping to an index in elasticsearch


[View source]
def self.bulk=(bulk : Bool) #

Whether or not to use the bulk api


[View source]
def self.bulk? : Bool #

Whether or not to use the bulk api


[View source]
def self.bulk_action(action, document, index, parents = [] of Parent, no_children = true) #

Generates the body of a Bulk request for a PostgreSQL record in ES

  • Creates document in table index
  • Adds document to all parent table indices, routing by the parent id

[View source]
def self.bulk_action_header(action : Action, index : String, id : String, routing : String | Nil = nil) #

Generates the header for an es action, precedes an optional document


[View source]
def self.bulk_operation(body) #

Make a request to the Elasticsearch bulk API endpoint

Throws on failure


[View source]
def self.bulk_request(action : Action, index : String, id : String, document_type : String, document_any : Hash(String, JSON::Any) | Nil = nil, parent_id : String | Nil = nil, no_children : Bool = true) #

Constructs the bulk request for a single ES document


[View source]
def self.check_index?(index) #

Check index present in elasticsearch


[View source]
def self.client(&) #

Yield an acquired client from the pool


[View source]
def self.configure(&) #

[View source]
def self.create_document(index, document, parents = [] of Parent, no_children = true) #

Create a new document in ES from a PgORM model


[View source]
def self.delete_all #

Delete all indices


[View source]
def self.delete_document(index, document, parents = [] of Parent) #

Delete a document in ES from a PgORM model


[View source]
def self.delete_index(index) #

Delete an index elasticsearch


[View source]
def self.delete_indices(indices) #

Delete several indices elasticsearch


[View source]
def self.document_join_field(document_type, parent_id = nil) #

Create a join field for a document body Can set just the document type if document is the parent


[View source]
def self.document_path(index, id, routing = nil) #

Constructs the ES path of a document


[View source]
def self.document_type(document) #

Picks off the model type from the class name


[View source]
def self.empty_indices(indices : Array(String) | Nil = nil) #

Remove documents from indices Removes from all indices if no argument given.


[View source]
def self.get_mapping?(index) : String | Nil #

Get the mapping applied to an index


[View source]
def self.headers #

Generate JSON header for ES requests


[View source]
def self.healthy? #

Checks availability of Elasticsearch


[View source]
def self.settings #

[View source]
def self.single_action(action : Action, document, index : String, parents : Array(Parent) = [] of Parent, no_children : Bool = true) #

Generates the body of a Bulk request for a PostgreSQL record in ES

  • Creates document in table index
  • Adds document to all parent table indices, routing by the parent id

[View source]
def self.single_delete(index : String, id : String, routing : String | Nil = nil) #

Single request delete


[View source]
def self.single_request(action : Action, index : String, id : String, document_type : String, document_any : Hash(String, JSON::Any) | Nil = nil, parent_id : String | Nil = nil, no_children : Bool = true) #

[View source]
def self.single_upsert(index : String, id : String, document, routing : String | Nil = nil) #

Single request upsert


[View source]
def self.skip_replication?(attributes, index : String, parents : Array(Parent)) #

Skip replication to own index if the document type is self-associated and has a parent


[View source]
def self.update_body(document) #

Embeds document inside doc field. the bulk api sucks


[View source]
def self.update_document(index, document, parents = [] of Parent, no_children = true) #

Update a document in ES from a PgORM model


[View source]

Instance Method Detail

def settings #

[View source]

Macro Detail

macro method_missing(call) #

[View source]