searchkick

Set Multi Tenant in Active Admin Controllers (required for Searchkick index)

五迷三道 提交于 2021-01-29 09:11:41
问题 I am using Active Admin in my multi tenant app. I also use Searchkick which has a custom tenant specific index in each model: class Budget < ApplicationRecord multi_tenant :company searchkick inheritance: true,index_name: -> { [MultiTenant.current_tenant.tenant_name, model_name.plural, Rails.env].join('_') } end The issue is that in AA this logic fails because on the tenant is set. I want to be able to set this in AA when updating a record. For example I would update http://localhost:4000

Searchkick word_start match with nested field

∥☆過路亽.° 提交于 2021-01-29 09:05:49
问题 I have a Rails app with searchkick gem. My model has a nested JSON field. I try to make it searchable with word_start match. When I set in explicitly like: class Post < ApplicationRecord searchkick word_start: [:nested_data_field] end I does not work, and I get error: {"type"=>"mapper_parsing_exception", "reason"=>"failed to parse [nested_data_field]", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:401"}} on item with id '2596' How can I make

reindex error when upgrading to elasticsearch 7

杀马特。学长 韩版系。学妹 提交于 2020-02-06 15:43:49
问题 We are currently using the searchkick gem and it works great. Recently I tried upgrading elasticsearch to 7 in my local development environment. I got it up and running using homebrew ( after researching that I needed to run rm -fr /usr/local/var/lib/elasticsearch ). When I went to reindex one of my models I got the following mapping error: Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping

how to use searchkick to index according to some conditions

故事扮演 提交于 2020-01-15 10:12:32
问题 I am using searchkick and rails4. I have an activerecord People, with attributes a,b,c. How can I do indexing only when b equals "type1", not indexing otherwise? Currently what I know is def search_data { a:a, b:b, c:c, } end 回答1: Per the docs: By default, all records are indexed. To control which records are indexed, use the should_index? method together with the search_import scope. This should work for your case: class People < ApplicationRecord searchkick # you probably already have this

How to do complex querying with logical operations by using searchkick

被刻印的时光 ゝ 提交于 2020-01-01 05:30:08
问题 Iam using searchkick library as an elasticsearch client for Product searching. https://github.com/ankane/searchkick It is possible to create 'OR' condition and 'AND' condition; AND operation Product.search where: {price: {lte: 200}, in_stock: true} OR operation Product.search where: {or: [[{in_stock: true}, {backordered: true}]]} But Iam stuck with creating multiple 'AND' 'OR' conditions with searchkick. I need something like A OR B OR ( C AND D ) or I need like this, A AND B AND ( C OR D )

Searchkick advanced search body clause nullifies where clause

自古美人都是妖i 提交于 2019-12-25 12:54:53
问题 If I do an advanced search with searchkick for elasticsearch-rails like so: products = Activity.search body: {query: {bool: {must: [{ range: { min_age: {lte: 5} } }, { range: { max_age: {gte: 3} } } ] } } }, where: { category: "Programs", start_time: '2015-07-22' } ... the where clause is not being applied. Is this to be expected? Must I use body to achieve all of my queries? Is there a way to get around this in searchkick? slow log output: [2015-07-29 21:03:53,369][INFO ][index.search

rake environment elastic search:import:all FORCE=y keeps failing

走远了吗. 提交于 2019-12-22 17:52:13
问题 I'm running search kick and elastic search and i keep trying to recreate my index because my rails app is crashing but this keeps failing too. I am very new to this so feeling quite lost. I run rake environment elasticsearch:import:all FORCE=y But the error is Starting up a new ElasticSearch client with [IMPORT] Loading models from: /home/ubuntu/workspace/sample_app/app/models 2016-03-11 16:32:07 +0000: [Faraday::ConnectionFailed] Connection refused - connect(2) for "localhost" port 9200 {

searchkick not returnign results with whitespaces

点点圈 提交于 2019-12-20 07:29:43
问题 so i have this searckick method: search_options = { misspellings: { edit_distance: 2 }, fields: [:eventname, :date, :city], order: { _score: :desc, date: :asc, eventname: :asc, city: :asc }, match: :word_start, suggest: true, page: params[:page], per_page: 20 } if params[:date_from].present? datefrom = params[:date_from].to_datetime.strftime('%Y-%m-%d') dateto = params[:date_to].to_datetime.strftime('%Y-%m-%d') search_options[:where] = { date: {gte: datefrom, lte: dateto} } end This isn't

Setting up Facets in Elasticsearch with Searchkick gem in Rails 4.1

一世执手 提交于 2019-12-18 12:39:18
问题 I want the users to be able to easily find a series so want to set up facets. I have followed the directions at seachkick and everything is working fine, but when I setup Facets, I am getting the following as the return. I want it to be like in their documentation. Hope someone can help. I get this in myapp.com/movies { "name"=> { "_type"=> "terms", "missing"=> 0, "total"=> 1, "other"=> 0, "terms"=> [ { "term"=> "Bloop", "count"=> 1 } ] }, "imdb"=> { "_type"=> "terms", "missing"=> 0, "total"=