Search code examples
ruby-on-railselasticsearchsearchkick

searchkick - The [standard] token filter has been removed


Here is my searchkick config for user model.

# frozen_string_literal: true

class User < ApplicationRecord
  # ..
  searchkick word_start: [:company_name],
             callbacks: :async,
             filterable: %i[id role bidded_to_projects],
             searchable: [:company_name]

  has_many :projects
  has_many :bids, foreign_key: :contractor_id

  def search_data
    {
      company_name: company_name,
      role: present_role,
      id: id,
      bidded_to_projects: bidded_to_projects
    }
  end

  def bidded_to_projects
    bids.joins(:project).select('projects.id').map(&:id)
  end

  class << self
    def fetch_contractors_to_invite(project_id:, sender_id:, search_text:)
      users_invited_by_current_user =
        User
        .joins(:received_invitations)
        .where('projects_invites.project_id = ? AND projects_invites.sender_id = ?',
               project_id,
               sender_id)
        .pluck('users.id')

      User.search(
        search_text,
        fields: [:company_name],
        where: {
          role: User::CONTRACTOR,
          id: { not: users_invited_by_current_user },
          bidded_to_projects: { not: project_id }
        },
        match: :word_start,
        includes: [:company_profile]
      )
    end
end

When I am trying to index it getting error as below.

irb(main):002:0> User.reindex
Traceback (most recent call last):
        1: from (irb):2
Elasticsearch::Transport::Transport::Errors::BadRequest ([400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The [standard] token filter has been removed."}],"type":"illegal_argument_exception","reason":"The [standard] token filter has been removed."},"status":400})
irb(main):003:0> 

What is wrong in my code that causing this error to happen?


Solution

  • As mentioned on the official ES Standard token filter reference, it's deprecated and removed from ES 7.X

    enter image description here