Source count index (#214)

* elasticsearch image index: add source_count

* images query: add source_count field
This commit is contained in:
mdashlw 2024-04-22 04:21:00 +03:00 committed by GitHub
parent f9a6240014
commit ea25f2a01e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -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,

View file

@ -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: