This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Flatten do | |
@doc """ | |
Flattens a list by recursively flattening the head and tail of the list | |
""" | |
def flatten([head | tail]), do: flatten(head) ++ flatten(tail) | |
def flatten([]), do: [] | |
def flatten(element), do: [element] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SELECT company, | |
# GREATEST(similarity(company.sourced_name, 'search term'), similarity(company.local_name, 'search term'), similarity(company.name, 'search term')) AS rank | |
# FROM "companies" company | |
# WHERE (similarity(company.sourced_name, 'search term') > 0.1::float) OR | |
# (similarity(company.local_name, 'search term') > 0.1::float) OR | |
# (similarity(company.name, 'search term') > 0.1::float) | |
# ORDER BY rank DESC | |
# LIMIT 5; | |
defmodule Company do |