0

If I put a document like this:

$ curl -XPOST "http://localhost:9200/test/test/" -d '
{
  "books": {
    "id1": {
        "name": "Hello World!"
    },
    "id2": {
        "name": "Hitchhiker Guide To The Galaxy"
    }
  }
}'

Then it creates a mapping like this:

$ curl -XGET "http://localhost:9200/test/test/_mapping"
{
  "test":{
    "mappings":{
      "test":{
        "properties":{
          "books":{
            "properties":{
              "id1":{
                "properties":{
                  "name":{
                    "type":"string"
                  }
                }
              },
              "id2":{
                "properties":{
                  "name":{
                    "type":"string"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

The properties / keys in the "books" object are dynamic and the mapping will grow endlessly. How can I make ES not look at the keys for "books" and make it understand that each value in "books" is of the same type? E.g. the mapping should not contain a new entry for each book id.

3
  • And why are you doing this? Why is the list of keys endlessly? Do you not give a meaning to this property? Commented Jun 23, 2015 at 11:49
  • Per document, there are like 1-5 entries in the map ("books" in this specific example). But because the ids are different for each document - the mapping continues to grow. Commented Jun 23, 2015 at 11:51
  • Why don't you make a property id and store the id number there? I think you are trying to solve this problem in the wrong way. Just my 2c. Commented Jun 23, 2015 at 12:27

1 Answer 1

-1

You can store only one document at a time, unless you use bulk upload. A single document could look like this:

$ curl -XPOST "http://localhost:9200/test/test/" -d '
{
    "id": "id1",
    "name": "Hello World!"
}'

Or:

$ curl -XPOST "http://localhost:9200/test/test/id1" -d '
{
    "name": "Hello World!"
}'
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.