Last Updated
Viewed 17 Times

I have a project, where I use Searchkick gem in order to fetch records from ElasticSearch first and then do further processing on them. The guys that initially implemented it added a sort option by two fields in base options in SearchKick:

def base options
{
   fields: %i[catalogue_number oe_numbers],
   match: :word_start,
   misspellings: false,
   where: @conditions,
   load: false,
   order: { sale_rotation_group: { order: :desc } }, { lauber_id_integer: { order: :desc } },
   highlight: @params[:highlight]
}
end

lauber_it_integer does not exist in the application database so it must be a field in ElasticSearch that they added.

Now I want to change this and instead of current order I want to tell SearchKick to tell ElasticSearch to order the records by the fields I added to the application database: images_count and parameters_count. So probably I need to add those new fields to ElasticSearch so it knows how to order the records. I changed the order option to

order: { images_count: { order: :desc } }

but now I am getting the error:

Searchkick::InvalidQueryError ([400] {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [images_count] in order to sort on","index_uuid":"WhC4XK8IRnmmfkPJMNmV1g","index":"parts_development_20191124205133405"}]

This will probably involve also some extra work on ElasticSearch to add data to those new fields, however I know very little about ElasticSearch. Could you give me some indications or hints on how I could solve my problem?

I installed analysis-ukrainian to Searchkick plugins. Now how should I use it via Searchkick?

I tried setting Searchkick language to "ukrainian" but an error accure during reindex:

Invalid stemmer class specified: Ukrainian.

Please, help me to solve this

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"=> 1,
    "other"=> 0,
    "terms"=> [
      {
        "term" => "http://www.bloop.com",
        "count" => 1
      }
    ]
  }
}

#app/views/movies/index.html.erb
<%= p @series.facets %>

#app/controllers/movies_controller.rb
def index
  query = params[:query].presence || "*"
  @movies = Movie.search(query, page: params[:page],
                                suggest: true,
                                per_page: 20,
                                facets: [:name, :imdb])
end

#db/schema.rb
create_table "movies", force: true do |t|
  t.string   "name"
  t.text     "description"
  t.string   "imdb"
  t.string   "year"
  t.datetime "created_at"
  t.datetime "updated_at"
end

I'm using Rails 4.1.4 with searchkick (1.3.0) so I can use elastic search.

I have User model

class User
  searchkick
  def search_data
    {
     name: username,
     email: email,
     created_at: created_at.strftime("%d-%m-%Y")
    }
  end
end

created_at in dd-MM-yyyy format. How can I search for date range, let's say date from 01-01-2014 to 01-01-2015.

I tired something like User.search('*', where: {created_at: {gte:'01-01-2014', lte: '01-01-2015' } }) without getting the right results.

Any help?

Similar Question 4 (1 solutions) : Searchkick Elasticsearch throwing a 400 error

Similar Question 6 (1 solutions) : Searchkick and PostgreSQL with money field type

Similar Question 7 (2 solutions) : Rails 4: Error installing elasticsearch & searchkick

Similar Question 8 (2 solutions) : Multiple Search terms using Ruby Searchkick

cc