Skip to content

Commit

Permalink
Handle documents without configuration based field mappings correctly
Browse files Browse the repository at this point in the history
If the map was empty when to document was indexed, OpenSearch will not add an empty map, instead omitting the key.
  • Loading branch information
dersmon committed Mar 3, 2025
1 parent 1efa150 commit 6c127ce
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions publication/lib/field_publication/publications/search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,16 @@ defmodule FieldPublication.Publications.Search do
]
end

def search_document_map_to_struct(%{
"id" => id,
"identifier" => identifier,
"category" => category,
"project_name" => project_name,
"publication_draft_date" => publication_draft_date,
"configuration_based_field_mappings" => configuration_based_field_mappings,
"full_doc" => full_doc,
"full_doc_as_text" => full_doc_as_text
}) do
def search_document_map_to_struct(map) do
%SearchDocument{
id: id,
identifier: identifier,
category: category,
project_name: project_name,
publication_draft_date: publication_draft_date,
configuration_based_field_mappings: configuration_based_field_mappings,
full_doc: Data.document_map_to_struct(full_doc),
full_doc_as_text: full_doc_as_text
id: map["id"],
identifier: map["identifier"],
category: map["category"],
project_name: map["project_name"],
publication_draft_date: map["publication_draft_date"],
configuration_based_field_mappings: map["configuration_based_field_mappings"] || %{},
full_doc: Data.document_map_to_struct(map["full_doc"]),
full_doc_as_text: map["full_doc_as_text"]
}
end

Expand Down

0 comments on commit 6c127ce

Please sign in to comment.