Skip to content

Instantly share code, notes, and snippets.

@matteomanzo
Created April 18, 2018 08:16
Show Gist options
  • Save matteomanzo/0428a73ca8cfe13ae94664c7d72d6034 to your computer and use it in GitHub Desktop.
Save matteomanzo/0428a73ca8cfe13ae94664c7d72d6034 to your computer and use it in GitHub Desktop.
QUERY_FIELDS = {
title: { types: [:fuzzy] },
formatted_text: { types: [:word] },
author: { boost: 3.0, types: [:word] }, # we define both the type and the boost, only for this word.
abstract_text: { types: [:fuzzy] },
location: { types: [:infix] },
technique: { types: [:prefix] },
}.freeze
def matching_text_scope(text)
Mastico::Query.new(query: text, fields: QUERY_FIELDS).apply(UffiziIndex::Artwork.all)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment