From ea25f2a01e3250ebde83901ba26375fc36cd19a6 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Mon, 22 Apr 2024 04:21:00 +0300 Subject: [PATCH] Source count index (#214) * elasticsearch image index: add source_count * images query: add source_count field --- lib/philomena/images/elasticsearch_index.ex | 2 ++ lib/philomena/images/query.ex | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/philomena/images/elasticsearch_index.ex b/lib/philomena/images/elasticsearch_index.ex index 64872d1a..0e5fb296 100644 --- a/lib/philomena/images/elasticsearch_index.ex +++ b/lib/philomena/images/elasticsearch_index.ex @@ -56,6 +56,7 @@ defmodule Philomena.Images.ElasticsearchIndex do size: %{type: "integer"}, sha512_hash: %{type: "keyword"}, source_url: %{type: "keyword"}, + source_count: %{type: "integer"}, tag_count: %{type: "integer"}, tag_ids: %{type: "keyword"}, tags: %{type: "text", analyzer: "keyword"}, @@ -130,6 +131,7 @@ defmodule Philomena.Images.ElasticsearchIndex do uploader: if(!!image.user and !image.anonymous, do: String.downcase(image.user.name)), true_uploader: if(!!image.user, do: String.downcase(image.user.name)), source_url: image.sources |> Enum.map(&String.downcase(&1.source)), + source_count: length(image.sources), file_name: image.image_name, original_format: image.image_format, processed: image.processed, diff --git a/lib/philomena/images/query.ex b/lib/philomena/images/query.ex index 81551580..69effbbd 100644 --- a/lib/philomena/images/query.ex +++ b/lib/philomena/images/query.ex @@ -69,7 +69,7 @@ defmodule Philomena.Images.Query do defp anonymous_fields do [ int_fields: - ~W(id width height comment_count score upvotes downvotes faves uploader_id faved_by_id tag_count pixels size), + ~W(id width height comment_count score upvotes downvotes faves uploader_id faved_by_id tag_count pixels size source_count), float_fields: ~W(aspect_ratio wilson_score duration), date_fields: ~W(created_at updated_at first_seen_at), literal_fields: