Home > Mobile >  Elasticsearch in Python: "unknown parameter [analyser] on mapper [institution] of type [text]&q
Elasticsearch in Python: "unknown parameter [analyser] on mapper [institution] of type [text]&q

Time:11-09

I'm trying to create my first index in Elasticsearch with Python. I keep getting errors of the type : "unknown parameter [analyser] on mapper [institution] of type [text]" or "index has not been configured in mapper" when trying to create the index. I've tried several ways of creating the index with "put_settings" and "put_mappings" methods but nothing works. I use version 7 of the Python API and Elasticsearch 7.12.0 on Docker. Here is my code.

def create_expert_index(index_name="expert_query"):
    es = connect()

    if es.indices.exists(index=index_name):
        es.indices.delete(index=index_name, ignore=[400, 404])

    mappings = {
        "settings": {
            "analysis": {
                "analyser": {
                    "standard_asciifolding": {
                        "type": "custom",
                        "tokenizer": "standard",
                        "filter": ["asciifolding", "lowercase"]
                    }
                }
            }
        },
        "mappings": {
            "properties":
                {
                    "first_name":
                        {
                            "type": "text",
                            "analyser": "standard_asciifolding"

                        },
                    "last_name":
                        {
                            "type": "text",
                            "analyser": "standard_asciifolding"
                        },
                    "email":
                        {
                            "type": "text",
                            "analyser": "standard_asciifolding"
                        },
                    "specializations":
                        {
                            "type": "text",
                            "analyser": "standard_asciifolding"
                        },
                    "institution":
                        {
                            "type": "text",
                            "analyser": "standard_asciifolding"
                        }
                }

        }
    }
    es.indices.create(index_name, body=mappings)

Tried creating the index with the create, put_settings and put_mappings methods. I expect the index to get created.

CodePudding user response:

You misspelled "analyzer" - you wrote it with "s" - "analyser". The rest of the request looks ok. Consider adding Kibana to your implementation, and test your requests with dev tools. That's a really simple way of correcting those mistakes. That's how I found this misspelling.

  • Related