user3368375
user3368375

Reputation: 57

Elastic search " settings " add in Python module

How the following settings can be add to python elastic search module. Please provide a example. I have created indexes and mappings. But I am stuck with settings.

curl -XPUT "http://localhost:9200/blurays " -d'
{
   "settings": {
     "analysis": {
     "filter": {
        "nGram_filter": {
           "type": "nGram",
           "min_gram": 2,
           "max_gram": 20,
           "token_chars": [
              "letter",
              "digit",
              "punctuation",
              "symbol"
           ]
        }
     },
     "analyzer": {
        "nGram_analyzer": {
           "type": "custom",
           "tokenizer": "whitespace",
           "filter": [
              "lowercase",
              "asciifolding",
              "nGram_filter"
           ]
        },
        "whitespace_analyzer": {
           "type": "custom",
           "tokenizer": "whitespace",
           "filter": [
              "lowercase",
              "asciifolding"
           ]
        }
     }
  }
 },

Upvotes: 2

Views: 5084

Answers (2)

KSR
KSR

Reputation: 231

If your index already exists, you can update its settings with elasticsearch.indices.put_settings.

Upvotes: 6

Neel
Neel

Reputation: 21315

You can use elasticsearch.indices.create and pass the settings as body.

Docs says:

create(*args, **kwargs)

Create an index in Elasticsearch. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html

Parameters:

  • index – The name of the index
  • body – The configuration for the index (settings and mappings)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout

So you can pass body with settings argument.

Upvotes: 2

Related Questions