forked from AkkomaGang/akkoma
fix empty queries returning 50 results
This commit is contained in:
parent
8378c3a8bc
commit
d1bb10c88e
2 changed files with 47 additions and 27 deletions
|
@ -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,6 +8,11 @@ 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)
|
||||||
|
|
||||||
|
if must == [] do
|
||||||
|
:skip
|
||||||
|
else
|
||||||
%{
|
%{
|
||||||
size: 50,
|
size: 50,
|
||||||
terminate_after: 50,
|
terminate_after: 50,
|
||||||
|
@ -17,26 +22,38 @@ def es_query(:activity, query) do
|
||||||
],
|
],
|
||||||
query: %{
|
query: %{
|
||||||
bool: %{
|
bool: %{
|
||||||
must: Parsers.Activity.parse(query)
|
must: must
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def es_query(:user, query) do
|
def es_query(:user, query) do
|
||||||
|
must = Parsers.User.parse(query)
|
||||||
|
|
||||||
|
if must == [] do
|
||||||
|
:skip
|
||||||
|
else
|
||||||
%{
|
%{
|
||||||
size: 50,
|
size: 50,
|
||||||
terminate_after: 50,
|
terminate_after: 50,
|
||||||
timeout: "5s",
|
timeout: "5s",
|
||||||
query: %{
|
query: %{
|
||||||
bool: %{
|
bool: %{
|
||||||
must: Parsers.User.parse(query)
|
must: must
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def es_query(:hashtag, query) do
|
def es_query(:hashtag, query) do
|
||||||
|
must = Parsers.Hashtag.parse(query)
|
||||||
|
|
||||||
|
if must == [] do
|
||||||
|
:skip
|
||||||
|
else
|
||||||
%{
|
%{
|
||||||
size: 50,
|
size: 50,
|
||||||
terminate_after: 50,
|
terminate_after: 50,
|
||||||
|
@ -48,6 +65,7 @@ def es_query(:hashtag, query) do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@impl Pleroma.Search
|
@impl Pleroma.Search
|
||||||
def search(%{assigns: %{user: user}} = _conn, %{q: query} = _params, _options) do
|
def search(%{assigns: %{user: user}} = _conn, %{q: query} = _params, _options) do
|
||||||
|
|
Loading…
Reference in a new issue