Sha256: 4aba9fd439649eb407093100d054a67f6bb5c358349edb8afa5f67d845d47ad1

Contents?: true

Size: 1000 Bytes

Versions: 15

Compression:

Stored size: 1000 Bytes

Contents

class SearchController < ApplicationController

  def index
    tags = { pre_tags: '<em class="hl">', post_tags: '</em>' }
    @artists = Artist.search \
      query: {
        multi_match: {
          query: params[:q],
          fields: ['name^10','members^2','profile']
        }
      },
      highlight: {
        tags_schema: 'styled',
        fields: {
          name:    { number_of_fragments: 0 },
          members_combined: { number_of_fragments: 0 },
          profile: { fragment_size: 50 }
        }
      }

    @albums = Album.search \
      query: {
        multi_match: {
          query: params[:q],
          fields: ['title^100','tracklist.title^10','notes^1']
        }
      },
      highlight: {
        tags_schema: 'styled',
        fields: {
          title: { number_of_fragments: 0 },
          'tracklist.title' => { number_of_fragments: 0 },
          notes: { fragment_size: 50 }
        }
      }
  end

  def suggest
    render json: Suggester.new(params)
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
elasticsearch-persistence-queryable-0.1.9 examples/music/search/search_controller.rb
elasticsearch-persistence-queryable-0.1.8 examples/music/search/search_controller.rb
elasticsearch-persistence-6.0.0.pre examples/music/search/search_controller.rb
elasticsearch-persistence-5.1.0 examples/music/search/search_controller.rb
elasticsearch-persistence-5.0.2 examples/music/search/search_controller.rb
elasticsearch-persistence-2.0.1 examples/music/search/search_controller.rb
elasticsearch-persistence-5.0.1 examples/music/search/search_controller.rb
elasticsearch-persistence-2.0.0 examples/music/search/search_controller.rb
elasticsearch-persistence-5.0.0 examples/music/search/search_controller.rb
elasticsearch-persistence-0.1.9 examples/music/search/search_controller.rb
elasticsearch-persistence-0.1.8 examples/music/search/search_controller.rb
elasticsearch-persistence-0.1.7 examples/music/search/search_controller.rb
elasticsearch-persistence-0.1.6 examples/music/search/search_controller.rb
elasticsearch-persistence-0.1.5 examples/music/search/search_controller.rb
elasticsearch-persistence-0.1.4 examples/music/search/search_controller.rb