How could i manage types in new versions ? another way?

Hi !
I'm new on elasticsearch indexing.
And i'm trying to migrate from v5 to v8, i know this is a big change and challenge.

I read about types are deprecated now.

So , how could i manage my data ?

Now I have 1 index per website, and each index has different types of information, for example:
multimedia,
people,
publications,
resources.

In v5 we have organized in types.

How could I manage it now ?

I used php, latest elasticsearch composer library, and custom php code to create map, index, etc

config:

{
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0,
        "index.mapping.total_fields.limit": 100000,
        "analysis": {
            "filter": {
                "partial_filter": {
                    "type": "edge_ngram",
                    "min_gram": 2,
                    "max_gram": 20,
                    "token_chars": [
                        "letter",
                        "digit"
                    ]
                }
            },
            "analyzer": {
                "partial-match": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "partial_filter"
                    ]
                },
                "exact-match": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                },
                "last-name": {
                    "type": "custom",
                    "tokenizer": "keyword",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            }
        }
    },
    "mappings": {
        "_default_": {
            "_all": {
                "enabled": true,
                "type": "string",
                "analyzer": "partial-match",
                "search_analyzer": "standard"
            },
            "dynamic_templates": [{
                "string_template": {
                    "match": "*",
                    "match_mapping_type": "string",
                    "mapping": {
                        "type": "string",
                        "analyzer": "partial-match",
                        "search_analyzer": "standard",
                        "fields": {
                            "{name}": {
                                "type": "text",
                                "index": "analyzed",
                                "analyzer": "partial-match",
                                "search_analyzer": "standard"
                            },
                            "exact-match": {
                                "type": "string",
                                "index": "analyzed",
                                "analyzer": "exact-match",
                                "search_analyzer": "exact-match"
                            }
                        }
                    }
                }
            }],
            "properties": {
                "post_title": {
                    "type": "text",
                    "analyzer": "partial-match",
                    "search_analyzer": "standard",
                    "fields": {
                        "sort-order": {
                            "type": "string",
                            "fielddata": true,
                            "index": "analyzed",
                            "analyzer": "last-name",
                            "search_analyzer": "last-name"
                        }
                    }
                },
                "date": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss"
                },
                "orderby_date": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss"
                },
                "post_status": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "visible": {
                    "type": "boolean",
                    "index": "not_analyzed"
                },
                "people": {
                    "type": "nested",
                    "properties": {
                        "id": {
                            "type": "integer",
                            "index": "not_analyzed"
                        },
                        "post_title": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                },
                "parent_blog": {
                    "type": "nested",
                    "properties": {
                        "id": {
                            "type": "integer",
                            "index": "not_analyzed"
                        }
                    }
                }
            }
        },
        "person": {
            "properties": {
                "last_name": {
                    "type": "text",
                    "analyzer": "partial-match",
                    "search_analyzer": "standard",
                    "fields": {
                        "raw": {
                            "type": "string",
                            "index": "not_analyzed"
                        },
                        "sort-order": {
                            "type": "string",
                            "fielddata": true,
                            "index": "analyzed",
                            "analyzer": "last-name",
                            "search_analyzer": "last-name"
                        },
                        "exact-match": {
                            "type": "string",
                            "index": "analyzed",
                            "analyzer": "exact-match",
                            "search_analyzer": "exact-match"
                        }
                    }
                },
                "first_name": {
                    "type": "text",
                    "analyzer": "partial-match",
                    "search_analyzer": "standard",
                    "fields": {
                        "raw": {
                            "type": "string",
                            "index": "not_analyzed"
                        },
                        "sort-order": {
                            "type": "string",
                            "fielddata": true,
                            "index": "analyzed",
                            "analyzer": "last-name",
                            "search_analyzer": "last-name"
                        },
                        "exact-match": {
                            "type": "string",
                            "index": "analyzed",
                            "analyzer": "exact-match",
                            "search_analyzer": "exact-match"
                        }
                    }
                }
            }
        }
    }
}

I'd suggest that you read Removal of mapping types in Elasticsearch 6.0 | Elastic Blog

thanks for your quickly response.

Reading that, an alternative could be add "type" or "post type" property/field to each property, correct ?

Yes that's one of the solutions. Or one index per type which is better if you have a lot of fields which are not shared by the different types.

But may be explain a bit more what are looking like typical documents and we might find other ideas :wink:

well ... this is a WordPress headless cms with some different customs post types. And a lot of information in each of them.
Now all are indexed by some custom process.

And i'm trying to use it on ES 8.6

For example now , I added item_type field to config and settings, and also to body that i'm indexing, and I have this error, only after add item_type field O_O

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"illegal_argument_exception","reason":"Failed to parse value [analyzed] as only [true] or [false] are allowed."}},"status":400}

It was fixed changing:
"match_mapping_type":"string",
to:
"match_mapping_type":"boolean",

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.