Problem when indexing nested object (Elasticsearch 5.6)

Hi there,
I have some problem when i want to index (by using cURL) nested object , assume i have to indices (restaurant_info and restaurant_payment) both two indices have nested object. But problem that occured was nested object in restaurant_info can index to server without error. In contrast, nested object restaurant_payment can't index to server.

Here's restaurant_info mappings
         {
           "mappings": {
             "fashion_brand_info": {
               "properties": {
                 "restaurant_customer_review_details": {
                   "type": "nested",
                   "properties": {
                     "customer_id": {
                       "type": "keyword"
                     },
                     "customer_review": {
                       "type": "text"
                     },
                     "customer_score": {
                       "type": "double"
                     },
                     "customer_username": {
                       "type": "text"
                     }
                   }
                 }
               }
             }
           }
         }

Sample nested object (that can index without error)

     {
       "restaurant_customer_review_details": [
         {
           "customer_id": "CR101",
           "customer_username": "Luke Skywalker",
           "customer_review": "This is the greatest restaurant ever!",
           "customer_score": 4
         },
         {
           "customer_id": "CR102",
           "customer_username": "Leia Organa",
           "customer_review": "quite good",
           "customer_score": 4
         },
         {
           "customer_id": "CR103",
           "customer_username": "Han Solo",
           "customer_review": "really good",
           "customer_score": 5
         }
       ]
     }
Here's restaurant_payment mappings (the problem index)
         {
           "mappings": {
             "restaurant_payment": {
               "properties": {
                 "restaurant_credit_card_details": {
                   "type": "nested",
                   "properties": {
                     "credit_card_bank": {
                       "type": "keyword"
                     },
                     "credit_card_condition": {
                       "type": "text"
                     },
                     "credit_card_privillage": {
                       "type": "text"
                     },
                     "credit_card_type": {
                       "type": "keyword"
                     }
                   }
                 }
               }
             }
           }
         }

Sample nested object (that always return error) it is contain in file "my_payment"

    {
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "ABC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "DFG",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    }
  ]
}

Here's the result when i indexed by cURL

 curl -s -H "Content-Type: application/x-ndjson" -XPOST "http://localhost:9200/restaurant_payment/_bulk" --data-binary @D:\my_payment.json`
             {
               "took": 7,
               "errors": true,
               "items": [
                 {
                   "index": {
                     "_index": "restaurant_payment",
                     "_type": "payment",
                     "_id": "R001",
                     "status": 400,
                     "error": {
                       "type": "illegal_argument_exception",
                       "reason": "object mapping [restaurant_credit_card_details] can't be changed from nested to non-nested"
                     }
                   }
                 }
               ]
             }

But when i indexed restaurant_payment by Kibana , It can index to server without error.

Now i confuse what's the problem, Is this a bug of cURL or my nested object structure are wrong.

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

What does my_payment.json contains?

Oh I'm so sorry for forgot to mention about my_payment file but now I edited.

my_payment file contained

{
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "ABC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "DFG",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    }
  ]
}

Could edit again your initial post? It contains citation characters (>) and can not be used to reproduce your issue. Thanks.

I already edit post. Thank you for your advice.

I tried this:

DELETE test
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "restaurant_credit_card_details": {
          "type": "nested",
          "properties": {
            "credit_card_bank": {
              "type": "keyword"
            },
            "credit_card_condition": {
              "type": "text"
            },
            "credit_card_privillage": {
              "type": "text"
            },
            "credit_card_type": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}
PUT test/doc/1
{
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "ABC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "DFG",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    }
  ]
}

This works very well.

Thank you , your code totally works.

But when i added another field to mappings and index new data (named my_payment_final) , same problem occurs again.

Index method (cURL)

{
  "took": 17,
  "errors": true,
  "items": [
    {
      "index": {
        "_index": "my_payment_final",
        "_type": " restaurant_payment",
        "_id": "R001",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "object mapping [restaurant_debit_card_details] can't be changed from nested to non-nested"
        }
      }
    }

Here's my new mappings

PUT /my_payment_final

{
  "mappings": {
    "restaurant_payment": {
      "properties": {
        "restaurant_id": {
          "type": "keyword"
        },
        "restaurant_name": {
          "type": "text"
        },
        "restaurant_payment_tag": {
          "type": "keyword"
        },
        "restaurant_rabbit_payment": {
          "properties": {
            "accept_rabbit": {
              "type": "keyword"
            },
            "rabbit_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_app_payment_details": {
          "type": "nested",
          "properties": {
            "app_name": {
              "type": "text"
            },
            "app_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_qr_payment_details": {
          "type": "nested",
          "properties": {
            "qr_app_name": {
              "type": "text"
            },
            "qr_app_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_credit_card_details": {
          "type": "nested",
          "properties": {
            "credit_card_bank": {
              "type": "keyword"
            },
            "credit_card_condition": {
              "type": "text"
            },
            "credit_card_privillage": {
              "type": "text"
            },
            "credit_card_type": {
              "type": "keyword"
            }
          }
        },
        "restaurant_debit_card_details": {
          "type": "nested",
          "properties": {
            "debit_card_bank": {
              "type": "keyword"
            },
            "debit_card_condition": {
              "type": "text"
            },
            "debit_card_privillage": {
              "type": "text"
            },
            "debit_card_type": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}

Here's my new file "my_payment_final.json" that i used bulk api by cURL

{
  "restaurant_id": "R001",
  "restaurant_name": "Vanilla",
  "restaurant_payment_tag": [
    "rabbit",
    "rabbitlinepay",
    "qr",
    "creditcard",
    "debitcard"
  ],
  "restaurant_rabbit_payment": {
    "accept_rabbit": "yes",
    "rabbit_privillage": "discount 10% when paid by rabbit"
  },
  "restaurant_app_payment_details": [
    {
      "app_name": "spay",
      "app_privillage": "discount 10% when paid by spay"
    },
    {
      "app_name": "apay",
      "app_privillage": "none"
    }
  ],
  "restaurant_qr_payment_details": [
    {
      "qr_app_name": "B-Bank",
      "qr_app_privillage": "Get bonus point"
    },
    {
      "qr_app_name": "B-banking",
      "qr_app_privillage": "discount 10% "
    }
  ],
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "B-Bank",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    },
    {
      "credit_card_type": "Mastercard",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "Unionpay",
      "credit_card_bank": "BB Bank",
      "credit_card_condition": "none",
      "credit_card_privillage": "none"
    }
  ],
  "restaurant_debit_card_details": [
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "B-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "Mastercard",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "Unionpay",
      "debit_card_bank": "BB-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    }
  ]
}

I tried this:

DELETE test
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "restaurant_id": {
          "type": "keyword"
        },
        "restaurant_name": {
          "type": "text"
        },
        "restaurant_payment_tag": {
          "type": "keyword"
        },
        "restaurant_rabbit_payment": {
          "properties": {
            "accept_rabbit": {
              "type": "keyword"
            },
            "rabbit_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_app_payment_details": {
          "type": "nested",
          "properties": {
            "app_name": {
              "type": "text"
            },
            "app_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_qr_payment_details": {
          "type": "nested",
          "properties": {
            "qr_app_name": {
              "type": "text"
            },
            "qr_app_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_credit_card_details": {
          "type": "nested",
          "properties": {
            "credit_card_bank": {
              "type": "keyword"
            },
            "credit_card_condition": {
              "type": "text"
            },
            "credit_card_privillage": {
              "type": "text"
            },
            "credit_card_type": {
              "type": "keyword"
            }
          }
        },
        "restaurant_debit_card_details": {
          "type": "nested",
          "properties": {
            "debit_card_bank": {
              "type": "keyword"
            },
            "debit_card_condition": {
              "type": "text"
            },
            "debit_card_privillage": {
              "type": "text"
            },
            "debit_card_type": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}
PUT test/doc/1
{
  "restaurant_id": "R001",
  "restaurant_name": "Vanilla",
  "restaurant_payment_tag": [
    "rabbit",
    "rabbitlinepay",
    "qr",
    "creditcard",
    "debitcard"
  ],
  "restaurant_rabbit_payment": {
    "accept_rabbit": "yes",
    "rabbit_privillage": "discount 10% when paid by rabbit"
  },
  "restaurant_app_payment_details": [
    {
      "app_name": "spay",
      "app_privillage": "discount 10% when paid by spay"
    },
    {
      "app_name": "apay",
      "app_privillage": "none"
    }
  ],
  "restaurant_qr_payment_details": [
    {
      "qr_app_name": "B-Bank",
      "qr_app_privillage": "Get bonus point"
    },
    {
      "qr_app_name": "B-banking",
      "qr_app_privillage": "discount 10% "
    }
  ],
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "B-Bank",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    },
    {
      "credit_card_type": "Mastercard",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "Unionpay",
      "credit_card_bank": "BB Bank",
      "credit_card_condition": "none",
      "credit_card_privillage": "none"
    }
  ],
  "restaurant_debit_card_details": [
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "B-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "Mastercard",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "Unionpay",
      "debit_card_bank": "BB-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    }
  ]
}

It gives:

{
  "_index": "test",
  "_type": "doc",
  "_id": "1",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 0,
  "_primary_term": 1
}

There is probably something you don't tell.
Anyway, if you can reproduce it, please provide a full script as I just gave again as it's easier to reproduce by just copying and pasting in Kibana dev console, then executing.

May I asked you something?
What's your index method (cURL or Kibana)?

This problem occured only when I used bulk index by cURL , It not happended when I index by Kibana dev console. Could it be possibly bug in cURL?

Misuse of bulk API IMO. You are probably missing the header or you have line returns in your doc line.

For a single doc, don't use _bulk

Sorry for typed not clear.

Actually , In "my_payment_final.json" included 3 documents (it will be increase later) but in previous reply I cut 2 last document off due to reply's limitation that's why I use bulk api by cURL. Here's my_payment_final.json contains

  {
  "restaurant_id": "R001",
  "restaurant_name": "Vanilla",
  "restaurant_payment_tag": [
    "rabbit",
    "rabbitlinepay",
    "qr",
    "creditcard",
    "debitcard"
  ],
  "restaurant_rabbit_payment": {
    "accept_rabbit": "yes",
    "rabbit_privillage": "discount 10% when paid by rabbit"
  },
  "restaurant_app_payment_details": [
    {
      "app_name": "spay",
      "app_privillage": "discount 10% when paid by spay"
    },
    {
      "app_name": "apay",
      "app_privillage": "none"
    }
  ],
  "restaurant_qr_payment_details": [
    {
      "qr_app_name": "B-Bank",
      "qr_app_privillage": "Get bonus point"
    },
    {
      "qr_app_name": "B-banking",
      "qr_app_privillage": "discount 10% "
    }
  ],
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "B-Bank",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    },
    {
      "credit_card_type": "Mastercard",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "Unionpay",
      "credit_card_bank": "BB Bank",
      "credit_card_condition": "none",
      "credit_card_privillage": "none"
    }
  ],
  "restaurant_debit_card_details": [
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "B-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "Mastercard",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "Unionpay",
      "debit_card_bank": "BB-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    }
  ]
}

{
  "restaurant_id": "R002",
  "restaurant_name": "Ros",
  "restaurant_payment_tag": [
    "rabbit",
    "rabbitlinepay",
    "qr",
    "creditcard",
    "debitcard"
  ],
  "restaurant_rabbit_payment": {
    "accept_rabbit": "yes",
    "rabbit_privillage": "discount 10% when paid by rabbit"
  },
  "restaurant_app_payment_details": [
    {
      "app_name": "spay",
      "app_privillage": "discount 10% when paid by spay"
    },
    {
      "app_name": "apay",
      "app_privillage": "none"
    }
  ],
  "restaurant_qr_payment_details": [
    {
      "qr_app_name": "B-Bank",
      "qr_app_privillage": "Get bonus point"
    },
    {
      "qr_app_name": "B-banking",
      "qr_app_privillage": "discount 10% "
    }
  ],
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "SBC",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "none"
    },
    {
      "credit_card_type": "VISA",
      "credit_card_bank": "B-Bank",
      "credit_card_condition": "Charge 3%",
      "credit_card_privillage": "get 100 point"
    }
  ],
  "restaurant_debit_card_details": [
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "SBC",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    },
    {
      "debit_card_type": "VISA",
      "debit_card_bank": "B-Bank",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    }
  ]
}

{
  "restaurant_id": "R003",
  "restaurant_name": "Nhai",
  "restaurant_payment_tag": [
    "rabbit",
    "rabbitlinepay"
  ],
  "restaurant_rabbit_payment": {
    "accept_rabbit": "yes",
    "rabbit_privillage": "discount 10% when paid by rabbit"
  },
  "restaurant_app_payment_details": [
    {
      "app_name": "none",
      "app_privillage": "none"
    }
  ],
  "restaurant_qr_payment_details": [
    {
      "qr_app_name": "none",
      "qr_app_privillage": "none"
    }
  ],
  "restaurant_credit_card_details": [
    {
      "credit_card_type": "none",
      "credit_card_bank": "none",
      "credit_card_condition": "none",
      "credit_card_privillage": "none"
    }
  ],
  "restaurant_debit_card_details": [
    {
      "debit_card_type": "none",
      "debit_card_bank": "none",
      "debit_card_condition": "none",
      "debit_card_privillage": "none"
    }
  ]
}

This file can not be sent as is.
You need to either conform to the bulk format or split the file and send one by one each doc.

I Index "my_payment_final.json" by cURL to index named "my_payment_final".

curl -s -H "Content-Type: application/x-ndjson" -XPOST "http://localhost:9200/my_payment_final/_bulk" --data-binary @D:\my_payment_final.json

Here's bulk api format

{"index":{"_index":"my_payment_final","_type":" restaurant_payment","_id":"R001"}}
{"restaurant_id":"R001","restaurant_name":"Vanilla","restaurant_payment_tag":["rabbit","rabbitlinepay","qr","creditcard","debitcard"],"restaurant_rabbit_payment":{"accept_rabbit":"yes","rabbit_privillage":"discount 10% when paid by rabbit"},"restaurant_app_payment_details":[{"app_name":"spay","app_privillage":"discount 10% when paid by spay"},{"app_name":"apay","app_privillage":"none"}],"restaurant_qr_payment_details":[{"qr_app_name":"B-Bank","qr_app_privillage":"Get bonus point"},{"qr_app_name":"B-banking","qr_app_privillage":"discount 10% "}],"restaurant_credit_card_details":[{"credit_card_type":"VISA","credit_card_bank":"SBC","credit_card_condition":"Charge 3%","credit_card_privillage":"none"},{"credit_card_type":"VISA","credit_card_bank":"B-Bank","credit_card_condition":"Charge 3%","credit_card_privillage":"get 100 point"},{"credit_card_type":"Mastercard","credit_card_bank":"SBC","credit_card_condition":"Charge 3%","credit_card_privillage":"none"},{"credit_card_type":"Unionpay","credit_card_bank":"BB Bank","credit_card_condition":"none","credit_card_privillage":"none"}],"restaurant_debit_card_details":[{"debit_card_type":"VISA","debit_card_bank":"SBC","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"VISA","debit_card_bank":"B-Bank","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"Mastercard","debit_card_bank":"SBC","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"Unionpay","debit_card_bank":"BB-Bank","debit_card_condition":"none","debit_card_privillage":"none"}]}

{"index":{"_index":"my_payment_final","_type":" restaurant_payment","_id":"R002"}}
{"restaurant_id":"R002","restaurant_name":"Ros","restaurant_payment_tag":["rabbit","rabbitlinepay","qr","creditcard","debitcard"],"restaurant_rabbit_payment":{"accept_rabbit":"yes","rabbit_privillage":"discount 10% when paid by rabbit"},"restaurant_app_payment_details":[{"app_name":"spay","app_privillage":"discount 10% when paid by spay"},{"app_name":"apay","app_privillage":"none"}],"restaurant_qr_payment_details":[{"qr_app_name":"B-Bank","qr_app_privillage":"Get bonus point"},{"qr_app_name":"B-banking","qr_app_privillage":"discount 10% "}],"restaurant_credit_card_details":[{"credit_card_type":"VISA","credit_card_bank":"SBC","credit_card_condition":"Charge 3%","credit_card_privillage":"none"},{"credit_card_type":"VISA","credit_card_bank":"B-Bank","credit_card_condition":"Charge 3%","credit_card_privillage":"get 100 point"}],"restaurant_debit_card_details":[{"debit_card_type":"VISA","debit_card_bank":"SBC","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"VISA","debit_card_bank":"B-Bank","debit_card_condition":"none","debit_card_privillage":"none"}]}

{"index":{"_index":"my_payment_final","_type":" restaurant_payment","_id":"R003"}}
{"restaurant_id":"R003","restaurant_name":"Nhai","restaurant_payment_tag":["rabbit","rabbitlinepay"],"restaurant_rabbit_payment":{"accept_rabbit":"yes","rabbit_privillage":"discount 10% when paid by rabbit"},"restaurant_app_payment_details":[{"app_name":"none","app_privillage":"none"}],"restaurant_qr_payment_details":[{"qr_app_name":"none","qr_app_privillage":"none"}],"restaurant_credit_card_details":[{"credit_card_type":"none","credit_card_bank":"none","credit_card_condition":"none","credit_card_privillage":"none"}],"restaurant_debit_card_details":[{"debit_card_type":"none","debit_card_bank":"none","debit_card_condition":"none","debit_card_privillage":"none"}]}

When I index by curl the error always occurred like this (I copy only id":"R001's result , result on id":"R002 and id":"R003 are same as R001)

{
  "took": 17,
  "errors": true,
  "items": [
    {
      "index": {
        "_index": "my_payment_final",
        "_type": " restaurant_payment",
        "_id": "R001",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "object mapping [restaurant_debit_card_details] can't be changed from nested to non-nested"
        }
      }
    }

Is there a blank space between your lines?

image

If so, fix it, it's not compatible with the bulk format.

BTW I ran this and it is working well.

DELETE test
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "restaurant_id": {
          "type": "keyword"
        },
        "restaurant_name": {
          "type": "text"
        },
        "restaurant_payment_tag": {
          "type": "keyword"
        },
        "restaurant_rabbit_payment": {
          "properties": {
            "accept_rabbit": {
              "type": "keyword"
            },
            "rabbit_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_app_payment_details": {
          "type": "nested",
          "properties": {
            "app_name": {
              "type": "text"
            },
            "app_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_qr_payment_details": {
          "type": "nested",
          "properties": {
            "qr_app_name": {
              "type": "text"
            },
            "qr_app_privillage": {
              "type": "text"
            }
          }
        },
        "restaurant_credit_card_details": {
          "type": "nested",
          "properties": {
            "credit_card_bank": {
              "type": "keyword"
            },
            "credit_card_condition": {
              "type": "text"
            },
            "credit_card_privillage": {
              "type": "text"
            },
            "credit_card_type": {
              "type": "keyword"
            }
          }
        },
        "restaurant_debit_card_details": {
          "type": "nested",
          "properties": {
            "debit_card_bank": {
              "type": "keyword"
            },
            "debit_card_condition": {
              "type": "text"
            },
            "debit_card_privillage": {
              "type": "text"
            },
            "debit_card_type": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}
POST test/_bulk
{"index":{"_index":"test","_type":"doc","_id":"R001"}}
{"restaurant_id":"R001","restaurant_name":"Vanilla","restaurant_payment_tag":["rabbit","rabbitlinepay","qr","creditcard","debitcard"],"restaurant_rabbit_payment":{"accept_rabbit":"yes","rabbit_privillage":"discount 10% when paid by rabbit"},"restaurant_app_payment_details":[{"app_name":"spay","app_privillage":"discount 10% when paid by spay"},{"app_name":"apay","app_privillage":"none"}],"restaurant_qr_payment_details":[{"qr_app_name":"B-Bank","qr_app_privillage":"Get bonus point"},{"qr_app_name":"B-banking","qr_app_privillage":"discount 10% "}],"restaurant_credit_card_details":[{"credit_card_type":"VISA","credit_card_bank":"SBC","credit_card_condition":"Charge 3%","credit_card_privillage":"none"},{"credit_card_type":"VISA","credit_card_bank":"B-Bank","credit_card_condition":"Charge 3%","credit_card_privillage":"get 100 point"},{"credit_card_type":"Mastercard","credit_card_bank":"SBC","credit_card_condition":"Charge 3%","credit_card_privillage":"none"},{"credit_card_type":"Unionpay","credit_card_bank":"BB Bank","credit_card_condition":"none","credit_card_privillage":"none"}],"restaurant_debit_card_details":[{"debit_card_type":"VISA","debit_card_bank":"SBC","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"VISA","debit_card_bank":"B-Bank","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"Mastercard","debit_card_bank":"SBC","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"Unionpay","debit_card_bank":"BB-Bank","debit_card_condition":"none","debit_card_privillage":"none"}]}
{"index":{"_index":"test","_type":"doc","_id":"R002"}}
{"restaurant_id":"R002","restaurant_name":"Ros","restaurant_payment_tag":["rabbit","rabbitlinepay","qr","creditcard","debitcard"],"restaurant_rabbit_payment":{"accept_rabbit":"yes","rabbit_privillage":"discount 10% when paid by rabbit"},"restaurant_app_payment_details":[{"app_name":"spay","app_privillage":"discount 10% when paid by spay"},{"app_name":"apay","app_privillage":"none"}],"restaurant_qr_payment_details":[{"qr_app_name":"B-Bank","qr_app_privillage":"Get bonus point"},{"qr_app_name":"B-banking","qr_app_privillage":"discount 10% "}],"restaurant_credit_card_details":[{"credit_card_type":"VISA","credit_card_bank":"SBC","credit_card_condition":"Charge 3%","credit_card_privillage":"none"},{"credit_card_type":"VISA","credit_card_bank":"B-Bank","credit_card_condition":"Charge 3%","credit_card_privillage":"get 100 point"}],"restaurant_debit_card_details":[{"debit_card_type":"VISA","debit_card_bank":"SBC","debit_card_condition":"none","debit_card_privillage":"none"},{"debit_card_type":"VISA","debit_card_bank":"B-Bank","debit_card_condition":"none","debit_card_privillage":"none"}]}
{"index":{"_index":"test","_type":"doc","_id":"R003"}}
{"restaurant_id":"R003","restaurant_name":"Nhai","restaurant_payment_tag":["rabbit","rabbitlinepay"],"restaurant_rabbit_payment":{"accept_rabbit":"yes","rabbit_privillage":"discount 10% when paid by rabbit"},"restaurant_app_payment_details":[{"app_name":"none","app_privillage":"none"}],"restaurant_qr_payment_details":[{"qr_app_name":"none","qr_app_privillage":"none"}],"restaurant_credit_card_details":[{"credit_card_type":"none","credit_card_bank":"none","credit_card_condition":"none","credit_card_privillage":"none"}],"restaurant_debit_card_details":[{"debit_card_type":"none","debit_card_bank":"none","debit_card_condition":"none","debit_card_privillage":"none"}]}

Also note that you have a bug here:

"_type":" restaurant_payment"

There is a space before restaurant_payment.

1 Like

Oh it's not at all , I've just put blank space between lines for make my data in pretty format.

My indexed file not have blank space.

The problem come from blank space issue. now I can index data by cURL without error.

Thank you so much , Mr.dadoonet

Lesson learned for your next post: please post exactly what you are doing as a full script as I always gave you. That will increase a lot your chances to get a response and have people testing it by just copy and paste your example.

1 Like

Ok , next post i'll fix my mistake.

Thank You for your help Mr.dadoonet.