How to story a JSON Array in an index via the Java client?

I am trying to store a JSON array (coming from an SQL Table field) within an Elasticsearch index. The JSON Array coming from the DB looks like this:

["Texas", "Texas", "Sidebet City"]

I get this array as a String from the database and I want to store this String as a JSON Array in an Elasticsearch index (knowing that Elasticsearch only knows Integer and String data types). When I try to use the following code of the Elasticsearch Java Client (v8.11) via storing the String value in a document object:

   for (CrawlingEntry crawlingEntry : crawlingEntries) {
        br.operations(op -> op
                .index(idx -> idx
                        .index(tableName)
                        .id(crawlingEntry.geturl_id().toString())
                        .document(crawlingEntry)
                )
        );

I see that the Array is stored with escape characters within the created index (and with outer parentheses):

 "locations": "[\"Texas\", \"Texas\", \"Sidebet City\"]"

What I need is this representation, though:

"locations": ["Texas", "Texas", "Sidebet City"]

(note the missing outer parentheses)

Is this actually possible with the Java client? How can I achieve this representation?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.