Source:
<code>public void addEntity(Entity entity) { LOGGER.debug("Adding/Updating the entity in ES"); String fieldToAdd = null; String fieldValueToAdd = ""; try { XContentBuilder builder = jsonBuilder() .startObject(); for(String field: docDef.fields()) { if(entity.get(field) != null) { <START> if(entity.getLanguage() != null && !entity.getLanguage().isEmpty() && isMultilingual) { <END> fieldToAdd = field + "_" + entity.getLanguage(); } else { fieldToAdd = field; } fieldValueToAdd = (String) entity.get(field); builder = builder.field(fieldToAdd, Arrays.asList(fieldValueToAdd)); break; } else { builder = builder.field(field, Collections.emptyList()); } } builder = builder.endObject(); IndexRequest indexRequest = new IndexRequest(INDEX_NAME, docDef.getEntityField(), entity.getId()) .source(builder); SearchResponse existsResponse = client.prepareSearch(INDEX_NAME) .setTypes(docDef.getEntityField()) .setQuery(QueryBuilders.existsQuery(fieldToAdd)) .get(); String script; if(existsResponse != null && existsResponse.getHits() != null && existsResponse.getHits().totalHits() > 0) { script = "ctx._source." + fieldToAdd+".add('"+ fieldValueToAdd + "')"; } else { script = "ctx._source." + fieldToAdd+" =['"+ fieldValueToAdd + "']"; } UpdateRequest upReq = new UpdateRequest(INDEX_NAME, docDef.getEntityField(), entity.getId()) .script(new Script(script)) .upsert(indexRequest); UpdateResponse response = client.update(upReq).get(); LOGGER.debug("Received the following Update response : " + response + " for the following entity: " + entity); } catch(Exception e) { throw new TextIndexException("Unable to Index the Entity in ElasticSearch.", e); } }</code><technical_language>Right. I suppose fine if intend language-specific analyzers Lucene index in multilingual mode (see org.apache.jena.query.text.analyzer.MultilingualAnalyzer Util for hooked up)</technical_language>

Target:
public void addEntity(Entity entity) { LOGGER.debug("Adding/Updating the entity in ES"); String fieldToAdd = null; String fieldValueToAdd = null; try { XContentBuilder builder = jsonBuilder() .startObject(); for(String field: docDef.fields()) { if(entity.get(field) != null) { if(entity.getLanguage() != null && !entity.getLanguage().isEmpty()) { fieldToAdd = normalizeFieldName(field, entity.getLanguage()); } else { fieldToAdd = field; } fieldValueToAdd = (String) entity.get(field); builder = builder.field(fieldToAdd, Arrays.asList(fieldValueToAdd)); break; } else { builder = builder.field(field, Collections.emptyList()); } } builder = builder.endObject(); IndexRequest indexRequest = new IndexRequest(indexName, docDef.getEntityField(), entity.getId()) .source(builder); String addUpdateScript = ADD_UPDATE_SCRIPT.replaceAll("<fieldName>", fieldToAdd); Map<String, Object> params = new HashMap<>(); params.put("fieldValue", fieldValueToAdd); UpdateRequest upReq = new UpdateRequest(indexName, docDef.getEntityField(), entity.getId()) .script(new Script(Script.DEFAULT_SCRIPT_TYPE, Script.DEFAULT_SCRIPT_LANG, addUpdateScript, params)) .upsert(indexRequest); UpdateResponse response = client.update(upReq).get(); LOGGER.debug("Received the following Update response : " + response + " for the following entity: " + entity); } catch(Exception e) { throw new TextIndexException("Unable to Index the Entity in ElasticSearch.", e); } }