Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.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 如何从elasticsearch的Tire gem中的搜索结果中删除_源_Ruby On Rails_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Tire - Fatal编程技术网 elasticsearch,tire,Ruby On Rails,elasticsearch,Tire" /> elasticsearch,tire,Ruby On Rails,elasticsearch,Tire" />

Ruby on rails 如何从elasticsearch的Tire gem中的搜索结果中删除_源

Ruby on rails 如何从elasticsearch的Tire gem中的搜索结果中删除_源,ruby-on-rails,elasticsearch,tire,Ruby On Rails,elasticsearch,Tire,我在Elasticsearch中为附件编制索引(通过Tiregem),它们非常大。不管出于什么原因,我没料到,搜索速度很慢。这似乎是因为Tire(ES)在其搜索结果中包含了文档的整个\u源代码。这是不必要的,但我不知道如何关闭它 直接与ES one通信可包括一个partial_fields元素来限制它: "partial_fields" : { "no_PDFs" : { "exclude" : ["attachment", "reports.attachment"] } }

我在Elasticsearch中为附件编制索引(通过Tiregem),它们非常大。不管出于什么原因,我没料到,搜索速度很慢。这似乎是因为Tire(ES)在其搜索结果中包含了文档的整个
\u源代码。这是不必要的,但我不知道如何关闭它

直接与ES one通信可包括一个
partial_fields
元素来限制它:

"partial_fields" : {
  "no_PDFs" : {
    "exclude" : ["attachment", "reports.attachment"]
  }
}
有人知道如何从轮胎搜索中排除元素吗

class Report < ActiveRecord::Base
  include Tire::Model::Search
  include Tire::Model::Callbacks
  ...
  tire.mapping do
    indexes :id, :type =>'integer'
    indexes :title
    indexes :attachment, :type => 'attachment', 
          :fields => {
          :author     => { :store => 'yes' },
          :attachment => { :term_vector => 'with_positions_offsets', :store => 'yes' },
          :date       => { :store => 'yes' }
    }
  end

  def self.search(params)
    tire.search do 
      query { string params[:query] } if params[:query].present? 
      highlight :attachment 
    end
  end
  ...
类报告'integer'
索引:标题
索引:附件,:type=>“附件”,
:字段=>{
:author=>{:store=>'yes'},
:attachment=>{:term_vector=>'带_位置_偏移',:store=>'是'},
:date=>{:store=>'yes'}
}
结束
定义自搜索(参数)
轮胎。搜索吗
查询{string params[:query]}如果params[:query]。是否存在?
推荐理由:附件
结束
结束
...

目前还没有直接支持内置轮胎

使用搜索方法的
字段
选项限制响应:

require 'tire'

Tire.index 'bigfields-test' do
  delete and create

  store title: 'Test 1', content: 'x'*100_000
  store title: 'Test 2', content: 'x'*100_000

  refresh
end

s = Tire.search 'bigfields-test', fields: 'title' do
  query { string 'test' }
end

p s.results

很好!谢谢但是,传递多个字段(或者排除字段的'except'选项)的语法是什么?我尝试了
字段:['title','id']
,其他尝试都没有成功。我知道ES想要一个数组,但轮胎似乎不想传递它。。。我错过了什么?明白了:
字段:“title,id”
。我猜空间并没有从与ES通信的URL中剥离。只是“发现”
:include\u in\u all=>false
。在映射中是否可以使用此选项从所有结果中消除:附件?类似于:
索引:附件,:type=>'attachment',:include_in_all=>false,
?!?