Skip to content

Instantly share code, notes, and snippets.

@deepakmahakale
Created July 5, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakmahakale/78e3ab8104bac2c54b2d2edba4e71e52 to your computer and use it in GitHub Desktop.
Save deepakmahakale/78e3ab8104bac2c54b2d2edba4e71e52 to your computer and use it in GitHub Desktop.

Change elasticsearch-rails & elasticsearch-model version

-gem 'elasticsearch-model', '0.1.8'
-gem 'elasticsearch-rails', '0.1.8'
+gem 'elasticsearch-rails', '~> 5.0.2'
+gem 'elasticsearch-model', '~> 5.0.2'

Bundle

bundle install

Create a new elasticsearch service on AWS and change the host url for elasticsearch

aws:
  services:
    elastic_search:
      connection:
-       host: 'http://localhost:9200'
+       host: 'https://search-nfhslearn-poc-cxxxxxxxxxxxx.us-east-1.es.amazonaws.com'

[Mapping Changes] Replace string with text/keyword

The string field datatype has been replaced by the text field for full text analyzed content, and the keyword field for not-analyzed exact string values.

-  indexes :email, type: :string, index: :not_analyzed
+  indexes :email, type: :keyword
-  indexes :first_name, type: :string, analyzer: :left_ngram
+  indexes :first_name, type: :text, analyzer: :left_ngram

Refer - https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_mapping_changes.html\#_literal_string_literal_fields_replaced_by_literal_text_literal_literal_keyword_literal_fields

[Mapping Changes] Remove multi-field as it is removed in 5.x

-  indexes :last_name, type: 'multi_field' do
-    indexes :last_name, analyzer: :left_ngram
-    indexes :raw, analyzer: :standard
-  end
+  indexes :last_name, type: :text, analyzer: :left_ngram do
+    indexes :raw, type: :keyword
+  end

Refer https://www.elastic.co/guide/en/elasticsearch/reference/5.0/multi-fields.html https://stackoverflow.com/questions/40301061/elasticsearch-5-mapperparserexception-with-multi-field

[Mapping Changes] Suggester changes

Mapping is changed. payloads is removed

{
  "mappings": {
    "song" : {
      "properties" : {
        "name" : { "type" : "string" },
        "suggest" : { "type" : "completion",
                      "index_analyzer" : "simple",
                      "search_analyzer" : "simple",
                      "payloads" : true
        }
      }
    }
  }
}

to

{
  "mappings": {
    "song" : {
      "properties" : {
        "suggest" : {
          "type" : "completion"
        },
        "title" : {
          "type": "keyword"
        }
      }
    }
  }
}

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-suggesters-completion.html

[Indexing Changes] Suggester changes

output and payload is removed changed from

PUT music/song/1?refresh=true
{
    "name" : "Nevermind",
    "suggest" : {
        "input": [ "Nevermind", "Nirvana" ],
        "output": "Nirvana - Nevermind",
        "payload" : { "artistId" : 2321 },
        "weight" : 34
    }
}

to

PUT music/song/1?refresh
{
    "suggest" : {
        "input": [ "Nevermind", "Nirvana" ],
        "weight" : 34
    }
}

[Querying Changes] Suggester changes

POST music/_suggest?pretty
{
    "song-suggest" : {
        "text" : "n",
        "completion" : {
            "field" : "suggest"
        }
    }
}

to

POST music/_suggest?pretty
{
    "song-suggest" : {
        "prefix" : "nir",
        "completion" : {
            "field" : "suggest"
        }
    }
}

Errors

< {"error":{"root_cause":[{"type":"parsing_exception","reason":"[nested] query does not support [filter]","line":1,"col":169}],"type":"parsing_exception","reason":"[nested] query does not support [filter]","line":1,"col":169},"status":400}
2018-01-18 17:52:52 +0530: [400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"[nested] query does not support [filter]","line":1,"col":169}],"type":"parsing_exception","reason":"[nested] query does not support [filter]","line":1,"col":169},"status":400}
Elastic Search Error:
#<Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"[nested] query does not support [filter]","line":1,"col":169}],"type":"parsing_exception","reason":"[nested] query does not support [filter]","line":1,"col":169},"status":400}>
Elastic Search Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment