2

I have defined the following index mapping for one of the documents:

{
   "favorites":{
      "_parent":{
         "type":"activities"
      },
      "properties":{
         "favorite_count":{
            "type":"integer"
         },
         "details":{
            "type":"integer",
            "store":"yes"
         }
      }
   }
}

When I try to index the following document :

{
      "favorite_count":3,
      "details":[
          1, 25, 4
      ]
}

I get the following exception :

org.elasticsearch.index.mapper.MapperParsingException: object mapping [details] trying to serialize a value with no field associated with it, current value [1]
    at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:595)
    at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:467)
    at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:599)
    at org.elasticsearch.index.mapper.object.ObjectMapper.serializeArray(ObjectMapper.java:587)
    at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:459)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:507)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:451)
    at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:329)
    at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:521)
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:419)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

From this link http://www.elasticsearch.org/guide/reference/mapping/array-type/ , I believe there is no problem with the index mapping. What am I doing wrong?

2
  • It sort of sounds like you're trying to push values into a field that has a non-compatible mapping - is the mapping you posted above what ES returns, or is it what you want your mapping to be? In either case, make sure that the mapping currently in use in ES matches what you want it to be. It sounds like you tried to update the mapping after it already had documents. Commented Sep 27, 2013 at 17:58
  • The issue is resolved. I was giving the index type name wrong in the rest api url, it should have been 'localhost:9200/test-app/favorites/_mapping', I was giving it as localhost:9200/test-app/ratings/_mapping. Commented Oct 29, 2013 at 18:10

2 Answers 2

3

When you have a parent/child relationship, you need to specify the parent when indexing a child document. See the Elasticsearch docs here: http://www.elasticsearch.org/blog/managing-relations-inside-elasticsearch/ You didn't say how you were indexing these; via curl it should look like this, where activity-id is the id of the parent document of this favorite:

curl -XPOST localhost:9200/favorites?parent=activity-id -d'
{
      "favorite_count":3,
      "details":[
          1, 25, 4
      ]
}'
Sign up to request clarification or add additional context in comments.

Comments

0

The issue is resolved. I was giving the index type name wrong in the rest api url, it should have been 'localhost:9200/test-app/favorites/_mapping';, I was giving it as localhost:9200/test-app/ratings/_mapping.

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.