mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Search fields (#100)
This commit is contained in:
parent
12ce4f82e1
commit
bcf295b1fa
5 changed files with 35 additions and 6 deletions
|
@ -5,7 +5,7 @@ defmodule Philomena.Analyzers.Webm do
|
|||
%{
|
||||
extension: "webm",
|
||||
mime_type: "video/webm",
|
||||
animated?: true,
|
||||
animated?: stats.animated?,
|
||||
duration: stats.duration,
|
||||
dimensions: stats.dimensions
|
||||
}
|
||||
|
@ -14,16 +14,16 @@ defmodule Philomena.Analyzers.Webm do
|
|||
defp stats(file) do
|
||||
case System.cmd("mediastat", [file]) do
|
||||
{output, 0} ->
|
||||
[_size, _frames, width, height, num, den] =
|
||||
[_size, frames, width, height, num, den] =
|
||||
output
|
||||
|> String.trim()
|
||||
|> String.split(" ")
|
||||
|> Enum.map(&String.to_integer/1)
|
||||
|
||||
%{dimensions: {width, height}, duration: num / den}
|
||||
%{animated?: frames > 1, dimensions: {width, height}, duration: num / den}
|
||||
|
||||
_ ->
|
||||
%{dimensions: {0, 0}, duration: 0.0}
|
||||
%{animated?: false, dimensions: {0, 0}, duration: 0.0}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
|||
mappings: %{
|
||||
dynamic: false,
|
||||
properties: %{
|
||||
animated: %{type: "boolean"},
|
||||
anonymous: %{type: "boolean"},
|
||||
aspect_ratio: %{type: "float"},
|
||||
comment_count: %{type: "integer"},
|
||||
|
@ -38,6 +39,8 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
|||
file_name: %{type: "keyword"},
|
||||
fingerprint: %{type: "keyword"},
|
||||
first_seen_at: %{type: "date"},
|
||||
fps: %{type: "float"},
|
||||
frames: %{type: "integer"},
|
||||
height: %{type: "integer"},
|
||||
hidden_by_user_ids: %{type: "keyword"},
|
||||
hidden_by_users: %{type: "keyword"},
|
||||
|
@ -48,6 +51,7 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
|||
orig_sha512_hash: %{type: "keyword"},
|
||||
original_format: %{type: "keyword"},
|
||||
pixels: %{type: "integer"},
|
||||
processed: %{type: "boolean"},
|
||||
score: %{type: "integer"},
|
||||
size: %{type: "integer"},
|
||||
sha512_hash: %{type: "keyword"},
|
||||
|
@ -55,6 +59,7 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
|||
tag_count: %{type: "integer"},
|
||||
tag_ids: %{type: "keyword"},
|
||||
tags: %{type: "text", analyzer: "keyword"},
|
||||
thumbnails_generated: %{type: "boolean"},
|
||||
true_uploader: %{type: "keyword"},
|
||||
true_uploader_id: %{type: "keyword"},
|
||||
updated_at: %{type: "date"},
|
||||
|
@ -100,7 +105,8 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
|||
height: image.image_height,
|
||||
pixels: image.image_width * image.image_height,
|
||||
size: image.image_size,
|
||||
duration: image.image_duration,
|
||||
animated: image.image_is_animated,
|
||||
duration: if(image.image_is_animated, do: image.image_duration, else: 0),
|
||||
tag_count: length(image.tags),
|
||||
aspect_ratio: image.image_aspect_ratio,
|
||||
wilson_score: wilson_score(image),
|
||||
|
@ -115,6 +121,8 @@ defmodule Philomena.Images.ElasticsearchIndex do
|
|||
source_url: image.source_url |> to_string |> String.downcase(),
|
||||
file_name: image.image_name,
|
||||
original_format: image.image_format,
|
||||
processed: image.processed,
|
||||
thumbnails_generated: image.thumbnails_generated,
|
||||
fingerprint: image.fingerprint,
|
||||
uploader_id: if(!!image.user_id and !image.anonymous, do: image.user_id),
|
||||
true_uploader_id: image.user_id,
|
||||
|
|
|
@ -74,6 +74,7 @@ defmodule Philomena.Images.Query do
|
|||
date_fields: ~W(created_at updated_at first_seen_at),
|
||||
literal_fields:
|
||||
~W(faved_by orig_sha512_hash sha512_hash uploader source_url original_format mime_type),
|
||||
bool_fields: ~W(animated processed thumbnails_generated),
|
||||
ngram_fields: ~W(description),
|
||||
custom_fields: ~W(gallery_id),
|
||||
default_field: {"namespaced_tags.name", :term},
|
||||
|
@ -106,7 +107,7 @@ defmodule Philomena.Images.Query do
|
|||
~W(fingerprint upvoted_by downvoted_by true_uploader hidden_by deleted_by_user),
|
||||
ngram_fields: fields[:ngram_fields] ++ ~W(deletion_reason),
|
||||
ip_fields: ~W(ip),
|
||||
bool_fields: ~W(deleted),
|
||||
bool_fields: fields[:bool_fields] ++ ~W(deleted),
|
||||
aliases:
|
||||
Map.merge(fields[:aliases], %{
|
||||
"upvoted_by" => "upvoters",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
defmodule Philomena.ThumbnailWorker do
|
||||
alias Philomena.Images.Thumbnailer
|
||||
alias Philomena.Images
|
||||
|
||||
def perform(image_id) do
|
||||
Thumbnailer.generate_thumbnails(image_id)
|
||||
|
@ -9,5 +10,9 @@ defmodule Philomena.ThumbnailWorker do
|
|||
"image:process",
|
||||
%{image_id: image_id}
|
||||
)
|
||||
|
||||
image_id
|
||||
|> Images.get_image!()
|
||||
|> Images.reindex_image()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ h1 Search
|
|||
a data-search-add="width:1920" data-search-select-last="4" data-search-show-help="numeric" Image width
|
||||
a data-search-add="height:1080" data-search-select-last="4" data-search-show-help="numeric" Image height
|
||||
a data-search-add="aspect_ratio:1" data-search-select-last="1" data-search-show-help="numeric" Aspect ratio
|
||||
a data-search-add="animated:false" data-search-select-last="5" data-search-show-help="boolean" Animated
|
||||
a data-search-add="duration:10" data-search-select-last="2" data-search-show-help="numeric" Duration (seconds)
|
||||
a data-search-add="pixels.gte:5000000" data-search-select-last="7" data-search-show-help="numeric" Pixels
|
||||
a data-search-add="size.lt:1048576" data-search-select-last="7" data-search-show-help="numeric" File size (bytes)
|
||||
|
@ -46,6 +47,20 @@ h1 Search
|
|||
a href="/pages/search_syntax" Help
|
||||
|
||||
.block__content
|
||||
.hidden.walloftext data-search-help="boolean"
|
||||
strong.js-search-help-subject>
|
||||
' is a Boolean-valued field. It only accepts the values
|
||||
code> true
|
||||
' and
|
||||
code false
|
||||
|.
|
||||
br
|
||||
br
|
||||
em<> Example:
|
||||
' to find images which are not animated, you would use
|
||||
code animated:false
|
||||
| .
|
||||
|
||||
.hidden.walloftext data-search-help="numeric"
|
||||
strong.js-search-help-subject>
|
||||
| is a numerical range field. Four qualifiers,
|
||||
|
|
Loading…
Reference in a new issue