private String categroy;
@Field(type = FieldType.Double)
private Double price;
}
使用ElasticsearchTemplate创建索引,添加映射
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = SearchServiceApplication.class)
public class ElasticsearchTest {
@Autowired
private ElasticsearchTemplate template;
@Test
public void createIndex(){
//删除索引
template.deleteIndex(Goods.class);
//创建索引
template.createIndex(Goods.class);
//添加映射,将字段映射到类型上
template.putMapping(Goods.class);
}
}
检查结果
=============================