Syed Zaidi
Syed Zaidi

Reputation: 1

Is my Elasticsearch analyzer being applied anywhere in my Rails model index mapping?

I have this mapping implementation currently in one of my models and I'm not sure if the analyzer is being applied:

  settings index: { analysis: { analyzer: { default: { type: :english } } } } do
    mappings do
      indexes :field1, type: :integer
      indexes :field2, type: :integer
      indexes :field3, type: :float
      indexes :field4, type: :text do
        indexes :keyword, type: :keyword
      end
      indexes :field5,    type: :text do
        indexes :keyword, type: :keyword
      end
      indexes :field6,    type: :text do
        indexes :keyword, type: :keyword
      end
      indexes :field7, type: :text
      indexes :field8, type: :boolean
    end
  end

I have seen implementations of analyzer usage where type of the field isn't declared, but the analyzer to be used is. Something like this:

  settings index: { analysis: { analyzer: { default: { type: :english } } } } do
    mappings do
      indexes :field1, analyzer: "default"
      indexes :field2, analyzer: "default"
      ...
    end
  end

So my question is, is the declared analyzer in my current implementation even doing anything?

Upvotes: 0

Views: 33

Answers (1)

Giritharan
Giritharan

Reputation: 51

Why you are try to use searchkick click here.

Because with help of that, you can handle best way of mapping across different models. moreover that you can write the query to elastic in best way, like our ORM (Active Record) in rails.

When you start working on project, you can focus more on application code instead of these kind of configuration things.

Let's give it try. it definitely make impact on your development journey. Hope you got an idea :)

Upvotes: 0

Related Questions