Search code examples
spring-data-elasticsearch

How to set routing when index document by ElasticsearchTemplate?


I am using ElasticsearchTemplate to index document into Elasticsearch. Now I have to set custome routing, however, I don't find how to set route in ElasticsearchTemplate.

I am using spring-data-elasticsearch-3.2.0.M4 to support RestClient.

             List<IndexQuery> queries = new ArrayList<IndexQuery>();
             IndexQuery e = new IndexQuery();
             e.setIndexName(map.get("index"));
             e.setSource(map.get("source"));
             if(map.get("id")!=null) {
                 e.setId(map.get("id"));     
             }
             queries.add(e );
             if(queries.size()>1000) {
                 esTemplate.bulkIndex(queries);
              }

I can find index,type,id,version,source etc in IndexQuery although I didn't find route field in IndexQuery. Does it not support route Or what am I missing ?


Solution

  • No, at the moment this is not supported. I created a Jira issue for this. Pleas feel free to vote or implement.