This commit is contained in:
Liam P. White 2019-08-26 20:00:48 -04:00
parent a0fa66628a
commit b5a9660fd0
2 changed files with 33 additions and 9 deletions

View file

@ -181,9 +181,11 @@ defmodule Philomena.Search.Lexer do
])
|> reduce({List, :to_string, []})
ip_address =
# choice([
ipv4_address |> optional(ipv4_prefix)#,
# ,
ip_address =
ipv4_address
|> optional(ipv4_prefix)
# ipv6_address |> optional(ipv6_prefix)
# ])
|> reduce({Enum, :join, []})

View file

@ -120,15 +120,37 @@ defmodule Philomena.Search.Parser do
defp search_fuzz(ctx, tokens) do
case tokens do
[{:int_field, field}, {:eq, _}, {:int, value}, {:fuzz, _}, {:number, fuzz} | r_tokens] ->
{%{range: %{try_alias(field) => %{gte: trunc(value - fuzz), lte: trunc(value + fuzz)}}}, r_tokens}
{%{
range: %{try_alias(field) => %{gte: trunc(value - fuzz), lte: trunc(value + fuzz)}}
}, r_tokens}
[{:float_field, field}, {:eq, _}, {:float, value}, {:fuzz, _}, {:number, fuzz} | r_tokens] ->
{%{range: %{try_alias(field) => %{gte: trunc(value - fuzz), lte: trunc(value + fuzz)}}}, r_tokens}
[
{:float_field, field},
{:eq, _},
{:float, value},
{:fuzz, _},
{:number, fuzz} | r_tokens
] ->
{%{
range: %{try_alias(field) => %{gte: trunc(value - fuzz), lte: trunc(value + fuzz)}}
}, r_tokens}
[{:literal_field, field}, {:eq, _}, {:text, value}, {:fuzz, _}, {:number, fuzz} | r_tokens] ->
[
{:literal_field, field},
{:eq, _},
{:text, value},
{:fuzz, _},
{:number, fuzz} | r_tokens
] ->
{%{fuzzy: %{try_alias(field) => %{value: value, fuzziness: fuzz}}}, r_tokens}
[{:ngram_field, field}, {:eq, _}, {:text, value}, {:fuzz, _}, {:number, fuzz} | r_tokens] ->
[
{:ngram_field, field},
{:eq, _},
{:text, value},
{:fuzz, _},
{:number, fuzz} | r_tokens
] ->
{%{fuzzy: %{try_alias(field) => %{value: value, fuzziness: fuzz}}}, r_tokens}
[{:default, [text: value]}, {:fuzz, _}, {:number, fuzz} | r_tokens] ->