Skip to content

Commit

Permalink
feat: PPT-1476 add es_ignore attribute to avoid dynamic mapping (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
naqvis authored Aug 15, 2024
1 parent 8134101 commit d2cf2ad
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
34 changes: 32 additions & 2 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
Lint/SpecFilename:
Description: Enforces spec filenames to have `_spec` suffix
Enabled: false
Severity: Warning

Lint/UselessAssign:
Description: Disallows useless variable assignments
Enabled: false
Severity: Warning

Naming/ConstantNames:
Description: Enforces constant names to be in screaming case
Enabled: false
Severity: Convention

Naming/BlockParameterName:
Description: Disallows non-descriptive block parameter names
Enabled: false
Severity: Convention

Lint/NotNil:
Description: Identifies usage of `not_nil!` calls
Enabled: false
Severity: Warning

Documentation/DocumentationAdmonition:
Description: Reports documentation admonitions
Enabled: false
Severity: Warning

Naming/QueryBoolMethods:
Description: Reports boolean properties without the `?` suffix
Enabled: false
Style/QueryBoolMethods:
Enabled: false
Severity: Convention
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
- ${PWD}/shard.override.yml:/app/shard.override.yml
- ${PWD}/shard.yml:/app/shard.yml.input
- ${PWD}/coverage:/app/coverage
- ${PWD}/.ameba.yml:/app/.ameba.yml
depends_on:
- elastic
- postgres
Expand Down
4 changes: 2 additions & 2 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shards:

connect-proxy:
git: https://github.com/spider-gazelle/connect-proxy.git
version: 2.0.1
version: 2.0.2

cron_parser:
git: https://github.com/kostya/cron_parser.git
Expand Down Expand Up @@ -162,7 +162,7 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 9.56.4
version: 9.57.0

placeos-resource:
git: https://github.com/place-labs/resource.git
Expand Down
2 changes: 1 addition & 1 deletion spec/table_manager_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module SearchIngest
# Check if updated schema applied
updated_schema.should_not eq JSON.parse(wrong_schema)

updated_schema["mappings"].should eq schema["mappings"]
updated_schema["mappings"].as_h.rehash.should eq schema["mappings"].as_h.rehash

updated_schema.dig("settings", "index", "analysis").as_h.rehash.should eq schema.dig("settings", "analysis").as_h.rehash
end
Expand Down
4 changes: 4 additions & 0 deletions src/search-ingest/schemas.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module SearchIngest
},
},
mappings: {
dynamic: false,
properties: property_mapping,
},
}.to_json
Expand Down Expand Up @@ -152,6 +153,8 @@ module SearchIngest
::Log.with_context do
Log.context.set(model: document_name, field: field.to_s)

next if options.tags[:es_ignore]?.try &.downcase.== "true"

type_tag = validate_tag(options.tags[:es_type]?)
subfield = validate_tag(options.tags[:es_subfield]?).try { |v| [v] }

Expand Down Expand Up @@ -335,6 +338,7 @@ module SearchIngest
else
tags = tags.each_with_object({} of Symbol => String) do |(k, v), object|
case v
when Bool then object[k] = v.to_s
when String then object[k] = v
when Symbol then object[k] = v.to_s
end
Expand Down

0 comments on commit d2cf2ad

Please sign in to comment.