Class: ElasticGraph::JSONIngestion::SchemaDefinition::Indexing::Field Private
- Inherits:
-
SchemaDefinition::Indexing::Field
- Object
- SchemaDefinition::Indexing::Field
- ElasticGraph::JSONIngestion::SchemaDefinition::Indexing::Field
- Defined in:
- elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Wraps an indexing field with JSON schema generation behavior.
Constant Summary collapse
- JSON_SCHEMA_OVERRIDES_BY_MAPPING_TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Note:We don't handle
integerhere because it's the default numeric type (handled by our definition of theIntscalar type).Note:Likewise, we don't handle
longhere because a custom scalar type must be used for that since GraphQL'sInttype can't handle long values.JSON schema overrides that automatically apply to specific mapping types so that the JSON schema validation will reject values which cannot be indexed into fields of a specific mapping type.
{ "byte" => {"minimum" => -(2**7), "maximum" => (2**7) - 1}, "short" => {"minimum" => -(2**15), "maximum" => (2**15) - 1}, "keyword" => {"maxLength" => DEFAULT_MAX_KEYWORD_LENGTH}, "text" => {"maxLength" => DEFAULT_MAX_TEXT_LENGTH} }
Instance Attribute Summary collapse
-
#doc_comment ⇒ String?
readonly
private
Documentation for the field.
-
#json_schema_customizations ⇒ Hash<Symbol, Object>
readonly
private
User-defined JSON schema customizations.
-
#json_schema_layers ⇒ Array<Symbol>
readonly
private
JSON schema wrapper layers from the field type reference.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
private
Compares fields, including JSON schema metadata tracked by this wrapper.
- #eql?(other) ⇒ Boolean private
-
#hash ⇒ Integer
private
Returns a hash code based on the wrapped field and JSON schema metadata.
-
#initialize(field, json_schema_layers:, json_schema_customizations:, doc_comment:) ⇒ Field
constructor
private
A new instance of Field.
-
#json_schema ⇒ Hash<String, Object>
private
Returns the JSON schema definition for this field.
-
#json_schema_metadata ⇒ JSONSchemaFieldMetadata
private
Metadata about this field for inclusion in the JSON schema.
- #nullable? ⇒ Boolean private
Methods inherited from SchemaDefinition::Indexing::Field
#mapping, normalized_mapping_hash_for
Constructor Details
#initialize(field, json_schema_layers:, json_schema_customizations:, doc_comment:) ⇒ Field
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Field.
51 52 53 54 55 56 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 51 def initialize(field, json_schema_layers:, json_schema_customizations:, doc_comment:) super(field) @json_schema_layers = json_schema_layers @json_schema_customizations = json_schema_customizations @doc_comment = doc_comment end |
Instance Attribute Details
#doc_comment ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns documentation for the field.
32 33 34 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 32 def doc_comment @doc_comment end |
#json_schema_customizations ⇒ Hash<Symbol, Object> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns user-defined JSON schema customizations.
29 30 31 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 29 def json_schema_customizations @json_schema_customizations end |
#json_schema_layers ⇒ Array<Symbol> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns JSON schema wrapper layers from the field type reference.
26 27 28 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 26 def json_schema_layers @json_schema_layers end |
Instance Method Details
#==(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Compares fields, including JSON schema metadata tracked by this wrapper.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 84 def ==(other) case other when Field __getobj__ == other.__getobj__ && json_schema_layers == other.json_schema_layers && json_schema_customizations == other.json_schema_customizations && doc_comment == other.doc_comment else super end end |
#eql?(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
96 97 98 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 96 def eql?(other) self == other end |
#hash ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a hash code based on the wrapped field and JSON schema metadata.
103 104 105 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 103 def hash [__getobj__, json_schema_layers, json_schema_customizations, doc_comment].hash end |
#json_schema ⇒ Hash<String, Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the JSON schema definition for this field.
61 62 63 64 65 66 67 68 69 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 61 def json_schema @json_schema ||= json_schema_layers .reverse # resolve layers from innermost to outermost wrappings .reduce(inner_json_schema) { |acc, layer| process_layer(layer, acc) } .merge(outer_json_schema_customizations) .merge({"description" => doc_comment}.compact) .then { |hash| Support::HashUtil.stringify_keys(hash) } end |
#json_schema_metadata ⇒ JSONSchemaFieldMetadata
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns metadata about this field for inclusion in the JSON schema.
72 73 74 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 72 def JSONSchemaFieldMetadata.new(type: type.name, name_in_index: name_in_index) end |
#nullable? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field.rb', line 76 def nullable? json_schema_layers.include?(:nullable) end |