0

I have a collection named templates. It has a field 'sec_1' which is an array of objects with properties 'name' and 'des' both of type string. Now I'm using elastic search and when I try to execute a query that matches only title fields I get an error saying the sec_1 field is not nested. Upon checking the mappings here is what I get mapping type of sec_1 is text.

I checked online and saw the fix was to modify the mapping. I created a new index like:

`curl base_url/new_index_name 

{
    "mappings": 
        {"properties": {
            "sec_1": {
                "type": 
                    "nested","properties": {
                        "name": { "type": "text" },
                        "des": { "type": "text" }
                        }
                     }
             }
    }
}

and then reindexed like this:

curl base_url/_reindex

{ 
    "source": {
        "index": "old_index"
    },
    "dest": {
        "index": "new_index"
    }
}`

First request is successful, the second one fails with this error:

{       
    "index": "new_index",       
    "type": "_doc",       
    "id": "be5123a4-d0e8-4d7b-a8f1-42f31d37fe55",       
    "cause": {         
        "type": "mapper_parsing_exception",         
            "reason": "object mapping for [sec_1] tried to parse field [null] as object, but found a concrete value"       
            },       
"status": 400     
},

I don't understand why this is happening and what I'm doing wrong. Please help. I do not know much about elastic search, I've looked for solutions online, tried chatgpt too but the same steps appear. I'm finding the reason for this error is that sec_1 is not nested type but I've checked in database it is an array of objects. What else could be wrong?

I tried creaing new index but cannot do that and without new index my search query cant function properly

MBD
  • 104
  • 5

0 Answers0