Method: Lcms::Engine::Search::Repository#standards_query

Defined in:
app/models/lcms/engine/search/repository.rb

#standards_query(term, options) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'app/models/lcms/engine/search/repository.rb', line 135

def standards_query(term, options)
  return term if term.respond_to?(:to_hash)

  limit = options.fetch(:per_page, 20)
  page = options.fetch(:page, 1)

  query = {
    query: {
      bool: {
        filter: [],
        should: [
          { term: { tag_standards: term } },
          { match_phrase_prefix: { tag_standards: { query: term } } }
        ],
        minimum_should_match: 1
      }
    },
    size: limit,
    from: (page - 1) * limit
  }

  apply_filters query, options
end