Module: ElasticGraph::Warehouse::SchemaDefinition::IndexExtension

Defined in:
elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/index_extension.rb

Overview

Extends SchemaDefinition::Indexing::Index to add warehouse table definition support.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#warehouse_table_defWarehouseTable? (readonly)

Returns the warehouse table definition for this index, if one has been defined via #warehouse_table.

Returns:

  • (WarehouseTable, nil)

    the warehouse table definition, or nil if none has been defined



20
21
22
# File 'elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/index_extension.rb', line 20

def warehouse_table_def
  @warehouse_table_def
end

Instance Method Details

#exclude_from_warehousevoid

This method returns an undefined value.

Excludes this index from the data warehouse configuration. This is useful when you have an index but don't want it to be included in the data warehouse.

Examples:

Exclude an internal/test index from the warehouse

ElasticGraph.define_schema do |schema|
  schema.object_type "InternalMetrics" do |t|
    t.field "id", "ID"

    t.index "internal_metrics" do |i|
      i.exclude_from_warehouse # This index won't be in the data warehouse
    end
  end
end


63
64
65
# File 'elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/index_extension.rb', line 63

def exclude_from_warehouse
  @warehouse_table_def = nil
end

#warehouse_table(name) ⇒ void

This method returns an undefined value.

Defines a warehouse table for this index with a custom name.

By default, a warehouse table is automatically created with the same name as the index. Use this method only when you need a different table name than the index name. To exclude an index from the warehouse entirely, use #exclude_from_warehouse instead.

Examples:

Override the default warehouse table name

ElasticGraph.define_schema do |schema|
  schema.object_type "Product" do |t|
    t.field "id", "ID"
    t.field "name", "String"

    t.index "products" do |i|
      # Override to use a different table name than "products"
      i.warehouse_table "store_products"
    end
  end
end

Parameters:

  • name (String)

    name of the warehouse table



43
44
45
# File 'elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/index_extension.rb', line 43

def warehouse_table(name)
  @warehouse_table_def = WarehouseTable.new(name: name, index: self)
end