Commit 3c8a3f0ff9ce6f53db2f7f12274ea33a0fcf5bf3

Authored by Joenio Costa
Committed by Macartur Sousa
1 parent 6add2953
Exists in elasticsearch_sort

check :weight exists

plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
... ... @@ -28,7 +28,13 @@ class ElasticsearchPluginController < ApplicationController
28 28 query = {}
29 29 unless text.blank?
30 30  
31   - fields = klass::SEARCHABLE_FIELDS.map {|k, v| "#{k}^#{v[:weight]}"}
  31 + fields = klass.indexable_fields.map do |key, value|
  32 + if value[:weight]
  33 + "#{k}^#{v[:weight]}"
  34 + else
  35 + "#{k}"
  36 + end
  37 + end
32 38  
33 39 query = {
34 40 query: {
... ...