Search code examples
ruby-on-railselasticsearchruby-on-rails-5elasticsearch-5chewy-gem

Getting error object field starting or ending with a [.]


While inserting the below document in an Elasticsearch index:

{
  "id": "122223334444",
  "name": "Mei",
  "url": "mei-2019-tamil",
  "alternate_urls": [
    "mei-2019-tamil",
    "sa-baskaran-aishwarya-rajesh-untitled"
  ],
  "type": "Movie",
  "poster": "ed3e439b-1ac1-45fe-a915-a5dae60257df",
  "poster_url": "//assets.appserver.com/ed3e439b-1ac1-45fe-a915-a5dae60257df",
  "alternate_names": [
    "Mei",
    "SA Baskaran - Aishwarya Rajesh Untitled"
  ],
  "popularity": 0.2,
  "info": {
    "running_time": 0,
    "cpl_types": [
      "teaser",
      "feature"
    ],
    "has_cpls": true,
    "genres": [
      "Drama",
      "Thriller"
    ],
    "international_release_date": null,
    "country_specific_release_dates": {},
    "international_film_status": "CS",
    "country_specific_film_statuses": {
      "IN": "CS",
      "CN": "CS",
      "": "CS",
      "SG": "CS"
    },
    "country_specific_certifications": {},
    "language": "Tamil",
    "synopsis": "A thriller film directed by SA Baskaran, starring Aishwarya Rajesh in the lead role.",
    "schedules": {
      "cities": [],
      "countries": []
    },
    "featured": 0,
    "movie_rating": 0,
    "cast": [
      {
        "id": "05ffe715-db60-4947-a45a-99722537571c",
        "name": "Aishwarya Rajesh",
        "url": "aishwarya-rajesh",
        "role": "Actress",
        "poster": "65ab15b6-d54a-4965-95d5-38a839cee17d",
        "poster_url": "//assets.appserver.com/65ab15b6-d54a-4965-95d5-38a839cee17d",
        "type": "Person"
      }
    ],
    "crew": [
      {
        "id": "d9354648-5f48-4bf0-9a00-3de8c4d7a8d0",
        "name": "SA Baskaran",
        "url": "sa-baskaran",
        "role": "Director",
        "poster": null,
        "poster_url": null,
        "type": "Person"
      }
    ]
  },
  "published": true
}

I'm getting the following Message:

Error: object field starting or ending with a [.] makes object resolution ambiguous:

However, there is no value that is starting with .

I am clueless as regards which key is causing this issue. Please help me identify and fix this issue.

ElasticSearch Version: 5.6.14

I am trying to index ES from a rails app using chewy gem.


Solution

  • Values of the JSON could be empty. But if the keys are empty then ES throws an error while indexing. Remove "":{} from the JSON and index again.

    Reference: https://discuss.elastic.co/t/object-field-starting-or-ending-with-a-makes-object-resolution-ambiguous/123351