Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 400在rails上的elasticsearch中使用自定义查询时出错_Ruby On Rails_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Ruby On Rails,elasticsearch" /> elasticsearch,Ruby On Rails,elasticsearch" />

Ruby on rails 400在rails上的elasticsearch中使用自定义查询时出错

Ruby on rails 400在rails上的elasticsearch中使用自定义查询时出错,ruby-on-rails,elasticsearch,Ruby On Rails,elasticsearch,我不知道如何在嵌套对象上使用过滤器和排序运行搜索查询。我一直在 [400] {"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; 我的可搜索关注点如下所示: module Searchable extend ActiveSupport::Concern included do include Elasticsearch::Model inc

我不知道如何在嵌套对象上使用过滤器和排序运行搜索查询。我一直在

[400] {"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed;
我的可搜索关注点如下所示:

module Searchable
  extend ActiveSupport::Concern

  included do
    include Elasticsearch::Model
    include Elasticsearch::Model::Callbacks

    def self.search(query="", options={})

       params = {
          query: {
            filtered: {
              query: {
                multi_match: {
                  query: query,
                  fields: ['title', 'description', 'product_url']
                },
                match_all: {}
              },
              filter: {
                bool: {
                  must: [
                    {
                      terms: {
                        gender: options[:gender]
                      }
                    },
                    {
                      nested: {
                        path: 'prices',
                        filter: {
                          bool: {
                            must: [
                              {
                                term: { 'prices.currency' => options[:p_curr] }
                              }
                            ]
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          sort: [
            {
              options[:order_col].try(:downcase) => {
                order: 'desc'
              }
            }
          ]
        }

        params[:query][:filtered][:query].delete(:match_all) if query.present?
        params[:query][:filtered][:query].delete(:multi_match) if query.blank?
        params.delete(:sort) if options[:order_col].blank?

        __elasticsearch__.search(params).page(options[:page]).per(options[:per_page])
      end

    # elastic search index
    # ---------------------------------------------------------------------------
    def as_indexed_json(options={})
      as_json(
        :only => [:title, :description, :product_url, :gender],
        :include => [
          :brand => {
            :only => [:name, :slug]
          }, 
          :retailer => {
            :only => [:name]
          }, 
          :product_text_tags => {
            :only => [:name]
          },
          :prices => {
            :only => [
              :price_in_cents,
              :currency,
              :is_on_sale,
              :out_of_stock,
              :on_sale_price_in_cents,
              :is_last_price
            ]
          }
        ]
      )
    end
    # ---------------------------------------------------------------------------
  end

end
我错过什么了吗?有人能帮忙吗。我觉得很失落。使用elastic时一切都很好,当我删除所有条件和过滤器时,使用普通查询时一切都很好
在Rails 3上工作

elasticsearch日志中应该有更多信息。正在提交的实际查询是什么?我在哪里可以找到日志?如果不将其后台化,elasticsearch将把这些内容打印到控制台,如果不打印,则默认情况下打印到logs文件夹中