0

here are two jsons:

json 1:

{
  "organization": [
    "Univ Philippines",
    {
      "pref": "Y",
      "content": "University of the Philippines System"
    },
    {
      "pref": "Y",
      "content": "University of the Philippines Diliman"
    }
  ]
}

json 2:

{
   "organization": "Univ Philippines"
}

I need index them into Elasticsearch. how to set organization field mapping?

I had tried string and object type but all failed.

PUT sci_test
{
  "mappings": {
    "sci":{
      "properties": {
        "organization":{
          "type": "object"
        }
      }
    }
  }
}
PUT sci_test/sci/1
{
  "organization": [
    "Univ Philippines",
    {
      "pref": "Y",
      "content": "University of the Philippines System"
    },
    {
      "pref": "Y",
      "content": "University of the Philippines Diliman"
    }
  ]
}

error info:
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "object mapping for [organization] tried to parse field [null] as object, but found a concrete value"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "object mapping for [organization] tried to parse field [null] as object, but found a concrete value"
  },
  "status": 400
}

1 Answer 1

2

All the fields must of of same type. You cannot mix string with object

"Univ Philippines",                                      --> text
 {                                                       --> object
      "pref": "Y",
      "content": "University of the Philippines System"
 }"

You need to define "Univ Philippines" as "University":"Univ Philippines"(add some key "university" etc).

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

Comments

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.