fix empty queries returning 50 results
This commit is contained in:
parent
8378c3a8bc
commit
d1bb10c88e
|
@ -142,6 +142,8 @@ def bulk_post([] = data, :hashtags) do
|
||||||
|
|
||||||
def bulk_post(_, :hashtags), do: {:ok, nil}
|
def bulk_post(_, :hashtags), do: {:ok, nil}
|
||||||
|
|
||||||
|
def search(_, _, _, :skip), do: []
|
||||||
|
|
||||||
def search(:raw, index, type, q) do
|
def search(:raw, index, type, q) do
|
||||||
with {:ok, raw_results} <- Elastix.Search.search(url(), index, [type], q) do
|
with {:ok, raw_results} <- Elastix.Search.search(url(), index, [type], q) do
|
||||||
results =
|
results =
|
||||||
|
|
|
@ -8,45 +8,63 @@ defmodule Pleroma.Search.Elasticsearch do
|
||||||
alias Pleroma.Web.Endpoint
|
alias Pleroma.Web.Endpoint
|
||||||
|
|
||||||
def es_query(:activity, query) do
|
def es_query(:activity, query) do
|
||||||
%{
|
must = Parsers.Activity.parse(query)
|
||||||
size: 50,
|
|
||||||
terminate_after: 50,
|
if must == [] do
|
||||||
timeout: "5s",
|
:skip
|
||||||
sort: [
|
else
|
||||||
%{"_timestamp" => "desc"}
|
%{
|
||||||
],
|
size: 50,
|
||||||
query: %{
|
terminate_after: 50,
|
||||||
bool: %{
|
timeout: "5s",
|
||||||
must: Parsers.Activity.parse(query)
|
sort: [
|
||||||
|
%{"_timestamp" => "desc"}
|
||||||
|
],
|
||||||
|
query: %{
|
||||||
|
bool: %{
|
||||||
|
must: must
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def es_query(:user, query) do
|
def es_query(:user, query) do
|
||||||
%{
|
must = Parsers.User.parse(query)
|
||||||
size: 50,
|
|
||||||
terminate_after: 50,
|
if must == [] do
|
||||||
timeout: "5s",
|
:skip
|
||||||
query: %{
|
else
|
||||||
bool: %{
|
%{
|
||||||
must: Parsers.User.parse(query)
|
size: 50,
|
||||||
|
terminate_after: 50,
|
||||||
|
timeout: "5s",
|
||||||
|
query: %{
|
||||||
|
bool: %{
|
||||||
|
must: must
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def es_query(:hashtag, query) do
|
def es_query(:hashtag, query) do
|
||||||
%{
|
must = Parsers.Hashtag.parse(query)
|
||||||
size: 50,
|
|
||||||
terminate_after: 50,
|
if must == [] do
|
||||||
timeout: "5s",
|
:skip
|
||||||
query: %{
|
else
|
||||||
bool: %{
|
%{
|
||||||
must: Parsers.Hashtag.parse(query)
|
size: 50,
|
||||||
|
terminate_after: 50,
|
||||||
|
timeout: "5s",
|
||||||
|
query: %{
|
||||||
|
bool: %{
|
||||||
|
must: Parsers.Hashtag.parse(query)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl Pleroma.Search
|
@impl Pleroma.Search
|
||||||
|
|
Loading…
Reference in a new issue