问题标签 [tire]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
634 浏览

ruby-on-rails - Elasticsearch / 轮胎:分面顺序

如何在轮胎中指定构面的顺序?

它可以在 Elasticsearch 中看到,如下所示: http ://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html

在轮胎中,它的默认设置为“计数”,但我不知道如何将其更改为“术语”顺序。

这是我的搜索方法:

结尾

0 投票
3 回答
800 浏览

ruby-on-rails - 如何使用条件导入索引

我的 Rails 3 中有一个名为 Article 的模型,我用rake environment tire:import CLASS='Article' FORCE=true它来做索引。但我只希望将字段deleted等于 false 的文章编入索引。我该如何实施?

0 投票
1 回答
5163 浏览

ruby - How to map / query this data with ElasticSearch?

I'm using ElasticSearch along with the tire gem to power the search functionality of my site. I'm having trouble figuring out how to map and query the data to get the results I need.

Relevant code is below. I will explain the desired outbut below that as well.

As you can see above, I'm doing some pre/post processing of the data to/from elasticsearch in order to get what i want from the 'product_traits' field. This is what doesn't feel right and where my questions originate.

I have a large catalog of products, each with a handful of 'traits' such as color, material and brand. Since these traits are so varied, I modeled the data to include a Trait model which relates to the Product model via a ProductTrait model, which holds the value of the trait for the given product.

First question is: How can i create the elasticsearch mapping to index these traits properly? I assume that this involves a nested type but I can't make enough sense of the docs to figure it out.

Second question: I want the facets to come back in groups (in the manner that I am processing them at the end of the search method above) but with counts that reflect how many matches there are without taking into account the currently selected value for each trait. For example: If the user searches for 'Glitter' and then clicks the link corresponding to the 'Blue Color' facet, I want all the 'Color' facets to remain visible and show counts correspinding the query results without the 'Blue Color' filter. I hope that is a good explanation, sorry if it needs more clarification.

0 投票
2 回答
3584 浏览

ruby-on-rails - 如何在 elasticsearch 中的同一字段上使用多个查询进行搜索?

我正在使用 ElasticSearch 和 Tire.rb 来索引和搜索我的项目集合。

我想查询索引中的名称字段。

如果我有一份名为Alfa Romeo的文件,我想通过以下搜索找到该文件:

  1. “阿尔法”
  2. “Alfa Remeo”(注意拼写错误)

在 ElasticSearch 和轮胎中,我知道如何分别设置两个查询:

使用通配符搜索:

模糊搜索(Levenshtein 距离):

如何结合(与或)?

我想要做的是找到通配符或模糊搜索匹配的所有文档。我可以进行两次单独的搜索并尝试将它们组合起来,但这没有多大意义。我可以以某种合乎逻辑的方式做到这一点吗?

0 投票
1 回答
710 浏览

ruby-on-rails - 如何从轮胎 gem 的搜索结果中删除 _source 以进行弹性搜索

我在 Elasticsearch 中索引附件(通过Tire gem),它们非常大。无论出于何种原因,我没想到会这样,搜索速度很慢。这似乎是因为轮胎(ES) 将整个_source文档包含在其搜索结果中。这是不必要的,但我不知道如何关闭它。

直接与 ES 通信可以包含一个partial_fields限制它的元素:

有人知道如何从轮胎搜索中排除元素吗?

0 投票
2 回答
603 浏览

ruby-on-rails - 几个非常具体的elasticsearch问题

我有一些关于 Rails + Tire + ElasticSearch 的非常具体的问题。

我已经看过 Railscast 关于它的内容,并且我已经阅读了很多文档,但老实说,这超出了我的想象。我希望有人能帮助我理解我无法完全掌握的细节。

这是我模型中的 Resource.rb elasticsearch 部分:

  1. “未分析”是什么意思?在我正在阅读的许多教程中,他们都使用它。如果不进行分析,为什么将其包含在mapping do?
  2. 使用索引的目的是什么。例如,类似indexes :id, type: 'integer'. 为什么需要对整数进行索引,这对性能有帮助吗?
  3. 如何修改 URL 的分析器以使其更好地工作?例如,如果它存储为http://www.dropbox.com,搜索dropbox.com不会找到结果,但www.dropbox.com会。我尝试粘贴所有不同的分析器,但没有一个真正适用于 URL
  4. 如果 mycategory.name存储为复数形式,例如“books”、“movies”、“tapes”,我如何告诉分析器根据单数和复数来查看这个词。搜索“电影”不起作用,但“电影”确实有效
  5. 当我删除load: true时,我的整个网站都会中断。他在railscast中回顾了这一点,但只是片刻。这是否意味着我需要将每个属性(和关联)移动到映射中,并将其更改为 :not_analyzed?(我刚刚意识到......也许我只是回答了我自己的问题#1!)。
  6. 一般来说,哪种类型的数据最适合 OR,哪种数据最适合 AND?就获得更多结果而言,我正在考虑或似乎更宽容
0 投票
1 回答
141 浏览

ruby-on-rails - Elasticsearch 需要映射*所有*关联?

我有一个大型模型(它基本上是我的整个应用程序)。我在这个模型上有 7 个或更多关联,包括多对多、:through => 等。这个模型还有一些简单的属性(标题、url 等)。

我唯一关心的索引是那些 3 或 4 个简单属性(标题、网址、描述、类别)。其他的我不关心。

当我使用 时,一切正常load: true,但一旦我关闭它,一切都会中断。解决这个问题的唯一方法似乎是为每个关联添加复杂的映射、:touch、:touch 回调等等?

我希望我理解错了,因为这将是大量代码,仅用于搜索 3 或 4 个简单属性。

我不知道我在说什么,但我是否可以搜索弹性搜索索引,但返回一个 ID 列表,然后以正常的 rails 方式循环遍历那些?

谢谢!

0 投票
0 回答
214 浏览

ruby-on-rails - 轮胎看不到单数/复数?

从我读过的所有内容来看,这应该有效。每次更改后我都会重新编制索引。

我的类别名称以复数形式存储,例如“书籍”、“电影”或“磁带”。在 Rails 术语中,这与@resource.category.name

如果我搜索它会起作用,books但如果我搜索它就不起作用book。我正在尝试这样做,以便您可以搜索单数或复数并找到该类别的结果

0 投票
1 回答
530 浏览

elasticsearch - 如何将弹性搜索 JSON 转换为轮胎兼容查询

我无法将以下有效的 JSON 查询转换为弹性搜索到 ruby​​ gem 'tire' 等效项。任何帮助都非常感谢...


0 投票
1 回答
229 浏览

ruby-on-rails - 每种语言的轮胎指数?

我在 Rails 模型上有以下轮胎映射:

能够涵盖多种语言的最佳方式是什么(如果我想添加英语或其他内容)?