Ejemplo n.º 1
0
  public void add(Bid bid) {

    System.out.println("elasticSearch");

    Long id = bid.getId();
    IndexQuery indexQuery =
        new IndexQueryBuilder().withId(String.valueOf(id)).withObject(bid).build();
    elasticsearchTemplate.bulkIndex(Arrays.asList(indexQuery));
  }
Ejemplo n.º 2
0
  public boolean add(List<Bid> bidList) {

    if (CollectionUtils.isEmpty(bidList)) {
      return true;
    }
    //		elasticsearchTemplate.createIndex(Bid.class);
    //		elasticsearchTemplate.putMapping(Bid.class);
    //		elasticsearchTemplate.refresh(Bid.class,true);
    ArrayList<IndexQuery> indexQueries = new ArrayList<>();
    for (Bid bid : bidList) {
      Long id = bid.getId();
      IndexQuery indexQuery =
          new IndexQueryBuilder().withId(String.valueOf(id)).withObject(bid).build();
      indexQueries.add(indexQuery);
    }
    elasticsearchTemplate.bulkIndex(indexQueries);
    elasticsearchTemplate.refresh(Bid.class, true);
    return true;
  }