mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
flatten gallery fields; preparation for removal of nested documents from index
This commit is contained in:
parent
cf72729ae7
commit
1a76cc484c
4 changed files with 9 additions and 3 deletions
2
.github/workflows/elixir.yml
vendored
2
.github/workflows/elixir.yml
vendored
|
@ -21,7 +21,7 @@ jobs:
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
image: elasticsearch:7.6.2
|
image: elasticsearch:7.8.1
|
||||||
ports: ['9200:9200']
|
ports: ['9200:9200']
|
||||||
redis:
|
redis:
|
||||||
image: redis:5.0.9
|
image: redis:5.0.9
|
||||||
|
|
|
@ -30,7 +30,7 @@ services:
|
||||||
driver: "none"
|
driver: "none"
|
||||||
|
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
image: elasticsearch:7.6.2
|
image: elasticsearch:7.8.1
|
||||||
volumes:
|
volumes:
|
||||||
- elastic_data:/var/lib/elasticsearch
|
- elastic_data:/var/lib/elasticsearch
|
||||||
logging:
|
logging:
|
||||||
|
|
|
@ -63,7 +63,9 @@ deleters: image_search_json
|
||||||
|
|
||||||
galleries: image_search_json
|
galleries: image_search_json
|
||||||
psql $(DATABASE) -v ON_ERROR_STOP=1 <<-SQL
|
psql $(DATABASE) -v ON_ERROR_STOP=1 <<-SQL
|
||||||
insert into temp_images.image_search_json (image_id, object) select gi.image_id, jsonb_build_object('gallery_interactions', jsonb_agg(jsonb_build_object('gallery_id', gi.gallery_id, 'position', gi.position))) from gallery_interactions gi group by image_id;
|
insert into temp_images.image_search_json (image_id, object) select gi.image_id, jsonb_build_object('gallery_interactions', jsonb_agg(jsonb_build_object('id', gi.gallery_id, 'position', gi.position))) from gallery_interactions gi group by image_id;
|
||||||
|
insert into temp_images.image_search_json (image_id, object) select gi.image_id, jsonb_build_object('gallery_id', jsonb_agg(gi.gallery_id)) from gallery_interactions gi group by image_id;
|
||||||
|
insert into temp_images.image_search_json (image_id, object) select gi.image_id, jsonb_build_object('gallery_position', jsonb_object_agg(gi.gallery_id, gi.position)) from gallery_interactions gi group by image_id;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
tags: image_search_json
|
tags: image_search_json
|
||||||
|
|
|
@ -73,6 +73,8 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
||||||
position: %{type: "integer"}
|
position: %{type: "integer"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
gallery_id: %{type: "keyword"},
|
||||||
|
gallery_position: %{type: "object", enabled: false},
|
||||||
namespaced_tags: %{
|
namespaced_tags: %{
|
||||||
properties: %{
|
properties: %{
|
||||||
name: %{type: "keyword"},
|
name: %{type: "keyword"},
|
||||||
|
@ -133,6 +135,8 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
||||||
namespaced_tags: %{
|
namespaced_tags: %{
|
||||||
name: image.tags |> Enum.flat_map(&([&1] ++ &1.aliases)) |> Enum.map(& &1.name)
|
name: image.tags |> Enum.flat_map(&([&1] ++ &1.aliases)) |> Enum.map(& &1.name)
|
||||||
},
|
},
|
||||||
|
gallery_id: Enum.map(image.gallery_interactions, & &1.gallery_id),
|
||||||
|
gallery_position: Map.new(image.gallery_interactions, &{&1.gallery_id, &1.position}),
|
||||||
favourited_by_users: image.favers |> Enum.map(&String.downcase(&1.name)),
|
favourited_by_users: image.favers |> Enum.map(&String.downcase(&1.name)),
|
||||||
hidden_by_users: image.hiders |> Enum.map(&String.downcase(&1.name)),
|
hidden_by_users: image.hiders |> Enum.map(&String.downcase(&1.name)),
|
||||||
upvoters: image.upvoters |> Enum.map(&String.downcase(&1.name)),
|
upvoters: image.upvoters |> Enum.map(&String.downcase(&1.name)),
|
||||||
|
|
Loading…
Reference in a new issue