Skip to content

Commit

Permalink
return failed doc
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Nov 26, 2024
1 parent c0b4c2d commit 908e509
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntry do

%{
id: id,
title_txtm: get_in(metadata, ["title"]) || ["Missing Title"],
title_txtm: extract_title(metadata),
description_txtm: get_in(metadata, ["description"]),
years_is: extract_years(data),
display_date_s: format_date(metadata),
Expand Down Expand Up @@ -84,6 +84,12 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntry do

defp extract_service_url(nil), do: nil

def extract_title(%{"title" => []}) do
["Missing Title"]
end

def extract_title(%{"title" => title}), do: title

defp is_derivative(%{
"mime_type" => ["image/tiff"],
"use" => [%{"@id" => "http://pcdm.org/use#ServiceFile"}]
Expand Down
12 changes: 11 additions & 1 deletion lib/dpul_collections/solr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ defmodule DpulCollections.Solr do

if response.status != 200 do
doc = docs |> Enum.at(0)
Logger.warning("error indexing solr document with id: #{doc["id"]} #{response.body}")

doc_s =
Enum.map_join(doc, ", ", fn {key, val} ->
cond do
is_list(val) -> "#{key}: [#{val}]"
true -> "#{key}: #{val}"
end
end)

# Logger.warning("error indexing solr document with id: #{doc["id"]} #{response.body}")
Logger.warning("error indexing solr document with id: #{doc["id"]} #{doc_s}")
end

response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntryTest do
"couldn't parse date"
end

test "an empty solr document is returned with a missing title" do
test "an empty solr document is returned with a empty title field" do
{:ok, entry} =
IndexingPipeline.write_hydration_cache_entry(%{
cache_version: 0,
Expand All @@ -293,6 +293,7 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntryTest do
"id" => "f134f41f-63c5-4fdf-b801-0774e3bc3b2d",
"internal_resource" => "EphemeraFolder",
"metadata" => %{
"title" => [],
"date_created" => ["2022"]
}
}
Expand Down

0 comments on commit 908e509

Please sign in to comment.