Soumya Ranjan Sahoo
Soumya Ranjan Sahoo

Reputation: 109

Why does elastic search returns response <Response [400]> when trying to index?

I was trying to follow the tutorial - http://ethen8181.github.io/machine-learning/search/bm25_intro.html#ElasticSearch-BM25

I successfully started my elastic node by running as a daemon and it did respond upon issuing the query - curl -X GET "localhost:9200/

When I try running the following code here, it returns 400.


settings = {
    'settings': {
        'index': {
            'number_of_shards': 1,
            'number_of_replicas': 1,

            'similarity': {
                'default': {
                    'type': 'BM25'
                }
            }
        }
    },
   
    'mappings': {
        '_doc': {
            'properties': {
                'title': {
                    'type': 'text',
                    'analyzer': 'english'
                }
            }
        }
    }
}
headers = {'Content-Type': 'application/json'}
response = requests.put('http://localhost:9200/experiment', data=json.dumps(settings), headers=headers)
response

What am I doing wrong here and how can I fix this?

I am basically trying to index a set of documents and retrieve them using BM25 ranking function.

Upvotes: 0

Views: 603

Answers (1)

Martynas Markevičius
Martynas Markevičius

Reputation: 154

Calling response.json() or response.text will give you the response body, which may tell you exactly what's wrong with the request

Upvotes: 1

Related Questions