Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ configure_local_rake_tasks = ->(tasks) do
FactoryBot.build(:widget, components: widget_components, inventor: Faker::Base.sample(inventors))
end)

batch.concat(Array.new(10) { FactoryBot.build(:online_store) })
batch.concat(Array.new(10) { FactoryBot.build(:physical_store) })
batch.concat(Array.new(10) { FactoryBot.build(:third_party_wholesale) })

batch.concat(sponsors = Array.new(10) { FactoryBot.build(:sponsor) })
batch.concat(Array.new(10) { FactoryBot.build(:team, sponsors: sponsors.sample(rand(3))) })
batch
Expand Down
10 changes: 10 additions & 0 deletions ai-memory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ The project is a monorepo composed of many gems. Each gem typically resides in i
- **Dependencies**: `elasticgraph-graphql`, `elasticgraph-indexer`, `elasticgraph-schema_artifacts`, `elasticgraph-support`, `graphql`, `graphql-c_parser`, `rake`.
- **Provides**: The schema definition framework and artifact generation capabilities.

### Index Inheritance

Abstract types (interfaces and unions) can declare an index that their concrete subtypes inherit, rather than each subtype declaring its own. Multiple concrete types then share a single datastore index. A subtype may still declare its own dedicated index, which overrides the inherited one — those documents are stored in a separate index and do not have `__typename` stored in them.

**`__typename` injection (indexer)**: When a record is indexed into a shared (inherited) index, the indexer automatically injects `__typename` into the document so the datastore can distinguish between concrete types at query time.

**Query-time scoping**: When an abstract type shares an index with types outside its subtype hierarchy, `QueryAdapter::AbstractTypeFilter` automatically injects an internal `__typename` filter scoped to the queried type's concrete subtypes.

**Key files**: `schema_definition/indexing/index.rb`, `schema_definition/mixins/has_indices.rb`, `schema_definition/schema_elements/type_with_subfields.rb`, `indexer/record_preparer.rb`, `graphql/query_adapter/abstract_type_filter.rb`, `graphql/schema/type.rb`.

## Other Key Information

This section highlights other important aspects of the ElasticGraph project:
Expand Down
36 changes: 23 additions & 13 deletions config/schema/artifacts/data_warehouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ tables:
shapes ARRAY<STRUCT<type STRING, coordinates ARRAY<FLOAT>>>,
manufacturer_id STRING
)
companies:
table_schema: |-
CREATE TABLE IF NOT EXISTS companies (
id STRING,
name STRING,
stock_ticker STRING
)
components:
table_schema: |-
CREATE TABLE IF NOT EXISTS components (
Expand All @@ -38,6 +31,14 @@ tables:
owner_ids ARRAY<STRING>,
owner_id STRING
)
distribution_channels:
table_schema: |-
CREATE TABLE IF NOT EXISTS distribution_channels (
id STRING,
established_on DATE,
active BOOLEAN,
__typename STRING
)
electrical_parts:
table_schema: |-
CREATE TABLE IF NOT EXISTS electrical_parts (
Expand All @@ -53,7 +54,7 @@ tables:
id STRING,
name STRING,
created_at TIMESTAMP,
ceo STRUCT<id STRING, name STRING, nationality STRING>
ceo STRUCT<id STRING, name STRING, nationality STRING, __typename STRING>
)
mechanical_parts:
table_schema: |-
Expand All @@ -64,12 +65,21 @@ tables:
material STRING,
manufacturer_id STRING
)
people:
named_inventors:
table_schema: |-
CREATE TABLE IF NOT EXISTS people (
CREATE TABLE IF NOT EXISTS named_inventors (
id STRING,
name STRING,
nationality STRING
nationality STRING,
__typename STRING,
stock_ticker STRING
)
physical_stores:
table_schema: |-
CREATE TABLE IF NOT EXISTS physical_stores (
id STRING,
established_on DATE,
active BOOLEAN
)
sponsors:
table_schema: |-
Expand Down Expand Up @@ -142,8 +152,8 @@ tables:
internal_details STRUCT<name STRING>,
internal_highlightable_details STRUCT<name STRING>,
the_opts STRUCT<size STRING, the_sighs STRING, color STRING, is_draft BOOLEAN>,
inventor STRUCT<id STRING, name STRING, nationality STRING, stock_ticker STRING, __typename STRING>,
named_inventor STRUCT<id STRING, name STRING, nationality STRING, stock_ticker STRING, __typename STRING>,
inventor STRUCT<id STRING, name STRING, nationality STRING, __typename STRING, stock_ticker STRING>,
named_inventor STRUCT<id STRING, name STRING, nationality STRING, __typename STRING, stock_ticker STRING>,
weight_in_ng_str BIGINT,
weight_in_ng BIGINT,
tags ARRAY<STRING>,
Expand Down
82 changes: 57 additions & 25 deletions config/schema/artifacts/datastore_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1531,30 +1531,6 @@ indices:
index.number_of_replicas: 1
index.number_of_shards: 1
index.max_result_window: 10000
companies:
aliases: {}
mappings:
dynamic: strict
properties:
id:
type: keyword
name:
type: keyword
stock_ticker:
type: keyword
__sources:
type: keyword
__versions:
type: object
dynamic: 'false'
_size:
enabled: true
settings:
index.mapping.ignore_malformed: false
index.mapping.coerce: false
index.number_of_replicas: 1
index.number_of_shards: 1
index.max_result_window: 10000
components:
aliases: {}
mappings:
Expand Down Expand Up @@ -1618,6 +1594,33 @@ indices:
index.number_of_replicas: 1
index.number_of_shards: 1
index.max_result_window: 10000
distribution_channels:
aliases: {}
mappings:
dynamic: strict
properties:
id:
type: keyword
established_on:
type: date
format: strict_date
active:
type: boolean
__typename:
type: keyword
__sources:
type: keyword
__versions:
type: object
dynamic: 'false'
_size:
enabled: true
settings:
index.mapping.ignore_malformed: false
index.mapping.coerce: false
index.number_of_replicas: 1
index.number_of_shards: 1
index.max_result_window: 10000
electrical_parts:
aliases: {}
mappings:
Expand Down Expand Up @@ -1709,7 +1712,7 @@ indices:
index.number_of_replicas: 1
index.number_of_shards: 1
index.max_result_window: 10000
people:
named_inventors:
aliases: {}
mappings:
dynamic: strict
Expand All @@ -1720,6 +1723,35 @@ indices:
type: keyword
nationality:
type: keyword
stock_ticker:
type: keyword
__typename:
type: keyword
__sources:
type: keyword
__versions:
type: object
dynamic: 'false'
_size:
enabled: true
settings:
index.mapping.ignore_malformed: false
index.mapping.coerce: false
index.number_of_replicas: 1
index.number_of_shards: 1
index.max_result_window: 10000
physical_stores:
aliases: {}
mappings:
dynamic: strict
properties:
id:
type: keyword
established_on:
type: date
format: strict_date
active:
type: boolean
__sources:
type: keyword
__versions:
Expand Down
67 changes: 67 additions & 0 deletions config/schema/artifacts/json_schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ json_schema_version: 1
- ElectricalPart
- Manufacturer
- MechanicalPart
- OnlineStore
- Person
- PhysicalStore
- Sponsor
- Team
- ThirdPartyWholesale
- Widget
- WidgetWorkspace
id:
Expand Down Expand Up @@ -445,6 +448,29 @@ json_schema_version: 1
oneOf:
- "$ref": "#/$defs/Person"
- "$ref": "#/$defs/Company"
OnlineStore:
type: object
properties:
id:
allOf:
- "$ref": "#/$defs/ID"
- maxLength: 8191
established_on:
anyOf:
- "$ref": "#/$defs/Date"
- type: 'null'
active:
anyOf:
- "$ref": "#/$defs/Boolean"
- type: 'null'
__typename:
type: string
const: OnlineStore
default: OnlineStore
required:
- id
- established_on
- active
Person:
type: object
properties:
Expand Down Expand Up @@ -472,6 +498,29 @@ json_schema_version: 1
- id
- name
- nationality
PhysicalStore:
type: object
properties:
id:
allOf:
- "$ref": "#/$defs/ID"
- maxLength: 8191
established_on:
anyOf:
- "$ref": "#/$defs/Date"
- type: 'null'
active:
anyOf:
- "$ref": "#/$defs/Boolean"
- type: 'null'
__typename:
type: string
const: PhysicalStore
default: PhysicalStore
required:
- id
- established_on
- active
Player:
type: object
properties:
Expand Down Expand Up @@ -819,6 +868,24 @@ json_schema_version: 1
- was_shortened
- players_nested
- players_object
ThirdPartyWholesale:
type: object
properties:
id:
allOf:
- "$ref": "#/$defs/ID"
- maxLength: 8191
active:
anyOf:
- "$ref": "#/$defs/Boolean"
- type: 'null'
__typename:
type: string
const: ThirdPartyWholesale
default: ThirdPartyWholesale
required:
- id
- active
Untyped:
type:
- array
Expand Down
Loading
Loading