saeedeh
saeedeh

Reputation: 89

object field starting or ending with a [.] makes object resolution ambiguous in elasticsearch bulk index

I am using elasticsearch version 6.8.7 with java rest high level client. I coded a program that uses bulk processor to bulk index some data to elasticsearch, according to the documentation provided here.

The problem is when I run my code, response fails with the message:

[type=illegal_argument_exception, reason=object field starting or ending with a [.] makes object resolution ambiguous

which is quite strange because I indexed one of the documents manually and it succeeded without any problem.

this is the part of the code that makes a index request:

        String key = entry.getKey();
        JSONObject val = entry.getValue();
        bulkProcessor.add(new IndexRequest("tweet").type("json").id(key).source(val, XContentType.JSON));

and this is a sample of the json (val in the above):

{"in_reply_to_status_id_str":null,"in_reply_to_status_id":null,"coordinates":null,"created_at":"Mon Apr 06 23:59:47 +0000 2020","truncated":false,"in_reply_to_user_id_str":null,"source":"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>","retweet_count":0,"retweeted":false,"geo":null,"in_reply_to_screen_name":null,"is_quote_status":false,"id_str":"11111111111111","in_reply_to_user_id":null,"favorite_count":7,"id":1111111111111,"text":"something","place":null,"contributors":null,"lang":"en","favorited":false}

If anyone has any ideas why this happens, I would very much appriciate their help.

update: I changed the index nothing changed but this is the error I get in elastic terminal:

object field starting or ending with a [.] makes object resolution ambiguous: [{"possibly_sensitive_appealable":false,"in_reply_to_status_id_str":null,"in_reply_to_status_id":null,"created_at":"Mon Apr 06 23:59:49 +0000 2020","in_reply_to_user_id_str":null,"source":"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>","quoted_status_id":1111111111111,"retweet_count":0,"retweeted":false,"geo":null,"in_reply_to_screen_name":null,"is_quote_status":true,"id_str":"111111111111","in_reply_to_user_id":null,"favorite_count":15,"id":1247313090397589511,"text":"something","place":null,"lang":"fa","favorited":false,"possibly_sensitive":false,"coordinates":null,"truncated":false,"quoted_status_id_str":"1111111111111","contributors":null}]

Upvotes: 0

Views: 749

Answers (1)

Harold Castillo
Harold Castillo

Reputation: 2416

I had the same problem, try to validate the properties, apparently all the properties in your index GET /index_name are store as String and not as a JSON object.

If this is your case:

The problem initially was with Kafka ConsumerRecord raw, I didn't set the types ConsumerRecord<String, String> and the problem was resolved.

Other option is to encode the string with a specific Encoding and also it works for me.

e.g.

IndexRequest indexRequest = new IndexRequest("twitter")
  .source(record.value().getBytes(StandardCharsets.US_ASCII), XContentType.JSON);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
String id = indexResponse.getId();
log.info(id);

I'm not pretty sure that this could help you, but in my case I resolve the problem with those changes.

Upvotes: 0

Related Questions