Unable to save to Elastic search with correct index

48 Views Asked by At

I'm getting data from service bus queue using jms Template receive method and then saving received data into elasticsearch. I have also created an endpoint for this . The issue I'm facing is first time when I'm hitting endpoint , it will fetch data from service bus and save it in elastic search. Again, if I hit my endpoint it's overwriting the index with new records. But I need to insert it as a new index , without replacing existing index data. All existing processed data should remain in the elastic search, it shouldn't overwrite. Like a primary key works while insertion as in a relational database.similar approach

Public void fetch () { List entities = new ArrayList<>();

Message m=jmsTemplate.receive("queue"); Product p=messageConverter.fromMessage(m); saveToElasticSearch (p, entities);

} private void saveToElasticSearch(Product p, List entities){

elasticEntity e = new elasticEntity(); e.setName(p.getName()); e setPrice(p.getPrice()); entities.add(e); repository.saveAll(entities);

}

In my entity class I have declared @Id Id Name and price variables

0

There are 0 best solutions below