From 2bdd801fbf5140854557cdb5675bde8c96d95314 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Wed, 25 May 2016 10:29:51 -0300 Subject: [PATCH] check :weight exists --- plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb b/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb index 64dd7f6..15c6c01 100644 --- a/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb +++ b/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb @@ -28,7 +28,13 @@ class ElasticsearchPluginController < ApplicationController query = {} unless text.blank? - fields = klass::SEARCHABLE_FIELDS.map {|k, v| "#{k}^#{v[:weight]}"} + fields = klass.indexable_fields.map do |key, value| + if value[:weight] + "#{k}^#{v[:weight]}" + else + "#{k}" + end + end query = { query: { -- libgit2 0.21.2