SpringdataSolr入门-批量插入数据

首先循环插入100条测试数据

    @Test

    public void testAddList(){

         List<TbItem> list=new ArrayList();

        

         for(int i=0;i<100;i++){

             TbItem item=new TbItem();

             item.setId(i+1L);

             item.setBrand("华为");

             item.setCategory("手机");

             item.setGoodsId(1L);

             item.setSeller("华为2号专卖店");

             item.setTitle("华为Mate"+i);

             item.setPrice(new BigDecimal(2000+i));

             list.add(item);

         }

        

         solrTemplate.saveBeans(list);

         solrTemplate.commit();

    }

猜你喜欢

转载自www.cnblogs.com/coder-wf/p/12517975.html