0

I'm trying to do a bulk insert using elastic search py, but I don't want to specify a type, but it won't allow me to specify None or "" for the value of type. How can I get around this?

bulk_data = []

this_merchant_product = {'field1': 'value1'}

op_dict = {
    "index": {
        "_index": "product",
        "_type": None,
        "_id": str(this_merchant_product_id)
    }
}

bulk_data.append(op_dict)
bulk_data.append(this_merchant_product)

es = Elasticsearch()
res = es.bulk(index='product', body=bulk_data)

I've also tried to set _type to "", but that doesn't work either.

These are the error messages.

This is the error when I set _type to None:

elasticsearch.exceptions.RequestError: RequestError(400, 'action_request_validation_exception', 'Validation Failed: 1: type is missing;

and this is the error I get when I set _type to "":

java.lang.IllegalArgumentException: name cannot be empty string
0

1 Answer 1

1

Each index has one mapping type in Elasticsearch 6.x+. In Elasticsearch 7.x+ type is removed. In version 2.x - 5.6 you could have used more then one mapping. Assuming that you’re using version 6.x, you need to have type of documents in index.

Sign up to request clarification or add additional context in comments.

1 Comment

Gotcha. It looks like the default type is "_doc" if you use elasticsearch-py, in case anyone finds that useful in the future. That's the only value for type that doesn't give me an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.