Search in sources :

Example 6 with Commodity

use of com.example.esdemo.dto.Commodity in project demo by breeze0630.

the class ElasticsearchTemplateTest method testInsert.

@Test
public void testInsert() {
    Commodity commodity = new Commodity();
    commodity.setSkuId("1501009005");
    commodity.setName("葡萄吐司面包(10片装)");
    commodity.setCategory("101");
    commodity.setPrice(160);
    commodity.setBrand("良品铺子");
    IndexQuery indexQuery = new IndexQueryBuilder().withObject(commodity).build();
    elasticsearchTemplate.index(indexQuery);
}
Also used : IndexQueryBuilder(org.springframework.data.elasticsearch.core.query.IndexQueryBuilder) Commodity(com.example.esdemo.dto.Commodity) IndexQuery(org.springframework.data.elasticsearch.core.query.IndexQuery) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Commodity (com.example.esdemo.dto.Commodity)6 Test (org.junit.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 ArrayList (java.util.ArrayList)1 MatchQueryBuilder (org.elasticsearch.index.query.MatchQueryBuilder)1 IndexQuery (org.springframework.data.elasticsearch.core.query.IndexQuery)1 IndexQueryBuilder (org.springframework.data.elasticsearch.core.query.IndexQueryBuilder)1 NativeSearchQueryBuilder (org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder)1 SearchQuery (org.springframework.data.elasticsearch.core.query.SearchQuery)1