Tag: 轮胎

如何使用Tire索引Elasticsearch中的附件?

难以通过Tire gem为elasticsearch索引附件类型。 无法正确设置附件type 。 我已经从Tire gem中引用了ActiveModel Integration示例 ,并在本地文件系统上添加了一个字段, filename ,用于引用我想要记录的索引。 #app/models/article.rb class Article ‘integer’ indexes :title indexes :content indexes :published_on, :type => ‘date’ indexes :attachment, :type => ‘attachment’ end def to_indexed_json to_json(:methods => [:attachment]) end def attachment if filename.present? path_to_pdf = “/Volumes/Disk41402/test_proj/sample_pdfs/#{filename}.pdf” Base64.encode64(open(path_to_pdf) { |pdf| pdf.read }) end end end FWIW – PDF似乎已添加到索引中: $ curl […]

如何设置轮胎弹性搜索的默认分析器?

我最近一直在尝试使用ruby on rails。 我无法将数据编入索引,因此我可以搜索包含复数和非复数关键字的项目。 轮胎将允许我为每个映射属性分配一个分析器: mapping do indexes title, analyzer: ‘snowball’ indexes body, analyzer: ‘snowball’ end 现在,假设我在“测试”标题中有一个关键字 如果我使用查询中的属性进行搜索: http:// localhost:9200 / myindex / mymapping / _search?q = title:test它将起作用。 但是,如果我在没有指定属性的情况下进行常规搜索,则: HTTP://本地主机:9200 / myindex / mymapping / _search Q =测试 它找不到该文件。 如何指定我希望默认分析器为“雪球”,因此我不必指定要搜索的属性? ps我正在使用轮胎gem。 所以请尽可能地回答这个问题。

Elasticsearch需要映射* all *关联吗?

我有一个大型模型(它基本上是我的整个应用程序)。 我在这个模型上有7个或更多的关联,包括多对多,:through =>等。这个模型也有一些简单的属性(标题,url等)。 我唯一关心索引的是那些3或4个简单属性(标题,url,描述,类别)。 其余我不在乎。 当我使用load: true时,一切都很完美load: true ,但是一旦我把它关掉,一切都会中断。 解决这个问题的唯一方法就是进入并添加复杂的映射,触摸,触摸回调等等每一个关联? 我希望我理解这个错误,因为这将只是搜索3或4个简单属性的大量代码。 我不知道我在说什么,但我可以搜索一下弹性搜索索引,但是返回一个ID列表,然后以正常的轨道方式循环遍历那些? 谢谢!

弹性搜索/轮胎:如何映射到关联属性?

我正在使用Tire进行弹性搜索。 在我的应用程序中,我有2个模型; 价格和产品。 我正在尝试搜索我的Price类并使用它所属的产品:name搜索字段的:name属性。 现在,如果我有一个名为Product 1并输入“pro”,“prod”或“duct”,则不会出现任何结果。 但输入“product”或“Product”会显示结果。 我相信问题在于我的映射。 我查看了查询及其: …localhost:3000/search/results?utf8=%E2%9C%93&query=product 当我认为它应该是: …localhost:3000/search/results?utf8=%E2%9C%93&query:product=product 从这个问题来看: ElasticSearch映射不起作用 我不知道如何让我的params[:query]只接受product.name 。 我尝试使用: string params[:query], default_field: “product.name”但是没有用。 我不想使用_all字段。 这是我的代码: Price.rb include Tire::Model::Search include Tire::Model::Callbacks def self.search(params) tire.search(load: true, page: params[:page], per_page: 20) do query do boolean do must { string params[:query] } if params[:query].present? must { term :private, false } end […]

在查询上使用Elasticsearch进行方面的麻烦

在我的查询中添加一个术语而不是filter时,我得到了0个方面。 仅供参考我正在使用Ruby的轮胎gem。 这是我的模型代码及其映射: class Property ‘snowball’, :boost => 100 indexes :description indexes :tags, type: ‘object’, properties: { name: { type: ‘multi_field’, fields: { name: { type: ‘string’, analyzer: ‘snowball’ }, exact: { type: ‘string’, index: ‘not_analyzed’ } } } } end def to_indexed_json to_json( include: { tags: { only: [:name] }, }) end 然后是搜索方法 def […]

使用elasticsearch来过滤带有空格的标签

我正在使用轮胎(https://github.com/karmi/tire)与mongoid。 这是我的模型定义: class SomethingWithTag include Mongoid::Document include Mongoid::Timestamps field :tags_array, type: Array include Tire::Model::Search include Tire::Model::Callbacks mapping do indexes :tags_array, type: :array, index: :not_analyzed end end 说我有一个文件{tags_array:[“hello world”]}。 然后以下查询工作正常: SomethingWithTag.tire.search { filter :terms, :tags_array => [“hello”] } SomethingWithTag.tire.search { filter :terms, :tags_array => [“world”] } SomethingWithTag.tire.search { filter :terms, :tags_array => [“hello”, “world”] } 但以下内容不会返回任何结果: […]

ElasticSearch&Tire:使用Mapping和to_indexed_json

在阅读Tire文档时,我的印象是你应该使用mapping或to_indexed_json方法,因为(我的理解是……) mapping用于提供to_indexed_json 。 问题是,我发现了一些使用它们的教程。 为什么? 基本上,我的应用程序现在使用to_indexed_json但我无法弄清楚如何设置某些属性的提升值(因此我开始查看映射的原因),我想知道是否使用两者会产生一些冲突。