tire

Elasticsearch sort based on the number of occurrences a string appears in an array

半世苍凉 提交于 2021-02-18 19:35:48
问题 I have an array field containig a list of strings: ie.: ["NY", "CA"] At search time I have a filter which matches any of the strings in the array. I would like to sort the results based on documents that have the most number of appearances of the searched string: "NY" Results should include: document 1: ["CA", "NY", "NY"] document 2: ["NY", FL"] document 3: ["NY", CA", "NY", "NY"] Results should be ordered as such User 3, User 1, User 2 Is this possible? If so, how? 回答1: For those curious, I

Elastic Search equivalent of “Scoping (Scalar Fields)” in sunspot/solr

本小妞迷上赌 提交于 2020-01-06 07:15:35
问题 I'm exploring various options for a search engine for our rails-app/data. I was able to make sunspot/solr work and am currently exploring ElasticSearch as an alternative but couldn't get the same thing(scoping/filtering) to work under ES. I would like to filter/scope objects as described in the "Scoping" section in 'https://github.com/sunspot/sunspot'. I have an active record class 'Product'. class Product < ActiveRecord::Base ... include Tire::Model::Search include Tire::Model::Callbacks

Elasticsearch with Tire: edgeNgram with multiple words

偶尔善良 提交于 2020-01-02 07:18:15
问题 Let's say I have 5 film titles: Sans Soleil Sansa So Is This Sol Goode Sole Survivor I want to implement an auto-complete search field with this expected behavior: "Sans" > Sans Soleil, Sansa "Sans so" > Sans Soleil "So" > So Is This, Sol Goode, Sole Survivor "So Is" > So Is This "Sol" > Sol Goode, Sole Survivor, Sans Soleil This use-case seems obvious and must be one utilized by many, but I just can't get it to work properly and I can't seem to find any answer or documentation to help. This

How can elasticsearch objects be boosted based on date or score

﹥>﹥吖頭↗ 提交于 2020-01-01 09:39:48
问题 For example, if something has a higher favorites_count I want it to be more relevant, or if it is updated more recently it is more relevant. Is there a way to do this? This is different than the standard boost functionality, because these fields don't contain keywords, they contain a numeric value. 回答1: You can use function_score to boost your doc base on a custom formula. Refer here ( script_score section) for more details: https://www.elastic.co/guide/en/elasticsearch/reference/current

How can elasticsearch objects be boosted based on date or score

梦想的初衷 提交于 2020-01-01 09:39:26
问题 For example, if something has a higher favorites_count I want it to be more relevant, or if it is updated more recently it is more relevant. Is there a way to do this? This is different than the standard boost functionality, because these fields don't contain keywords, they contain a numeric value. 回答1: You can use function_score to boost your doc base on a custom formula. Refer here ( script_score section) for more details: https://www.elastic.co/guide/en/elasticsearch/reference/current

Elastic Search nested

社会主义新天地 提交于 2019-12-25 18:21:45
问题 I'm using Elastic search through tire gem. Given this structure to index my resource model mapping do indexes :_id indexes :version, analyzer: 'snowball', boost: 100 indexes :resource_files do indexes :_id indexes :name, analyzer: 'snowball', boost: 100 indexes :resource_file_category do indexes :_id indexes :name, analyzer: 'snowball', boost: 100 end end end How can i retrieve all the resources that have resource_files with a given resource_file_category id? i've looked in the elastic search

rails - tire - elasticsearch : need to restart elasticsearch server

心不动则不痛 提交于 2019-12-25 05:27:17
问题 I use rails - tire - elasticsearch, everything is mainly working very well, but just from time to time, my server start to be very slow. So I have to restart elasticsearch service and then everything go fine again. I have impression that it happens after bulk inserts (around 6000 products). Can it be linked? Inserts last like 2 min max, but still after server has problem EDIT : finally it is not linked to bulk inserts I have only this line in log [2013-06-29 01:15:32,767][WARN ][monitor.jvm ]

How to sort with elasticsearch?

人走茶凉 提交于 2019-12-25 04:08:11
问题 I am trying to make methods for sorting desc and asc . I am using rails, tire gem and elasticsearch. I am trying to figure out what sort params I can send in the URL So I have defined in the search-block that it is sorting the result desc order. sort { by :price, "desc"} When a user search for apartments in: new-york the result is sort desc order. The search query/URL looks like this: http://localhost:3000/apartmens?utf8&query=newyork Why cant I add a sort-params in the url, like this: http:/

ElasticSearch and Tire : how to use html_strip

霸气de小男生 提交于 2019-12-24 13:30:35
问题 I'd like to add the char_filter html_strip in my Rails Project. But I'm not sure how and where to do it with the (re)tire gem. I'm not even sure it's possible the way I'm doing it. My code for the moment : include Tire::Model::Search include Tire::Model::Callbacks mapping do indexes :author, type: 'string' indexes :content, type: 'string', index_options: "offsets", analyzer: 'snowball', language: "French", char_filter: 'html_strip' indexes :name, type: 'string', index_options: "offsets",

Multiple Elasticsearch Indexes

老子叫甜甜 提交于 2019-12-24 10:46:50
问题 I have a staging & production instance of a Rails 3 application (using the tire gem) on the same Ubuntu server. It appears that both of these instances are sharing the same elasticsearch index which obviously isn't what I want. How can I get my production and staging instances to use separate instances? 回答1: You need override the index name. Assuming you're tying into ActiveRecord it will create an index name based on the model in question. You could adjust the name with a prefix like so;