Es 쿼리(모호, 정밀, 다중 조건, 수정, 편집, 삭제

2965 단어 elasticsearch
설정 파일jar----------------------------------------------------------------------------


    org.elasticsearch.client
    transport
    6.2.2



    com.fasterxml.jackson.core
    jackson-databind
    2.8.5


    com.fasterxml.jackson.core
    jackson-annotations
    2.8.5


    org.javassist
    javassist
    3.21.0-GA


    joda-time
    joda-time
    2.9


    io.dropwizard.metrics
    metrics-core
    3.1.0


    com.hankcs
    hanlp
    portable-1.3.1.3


    com.cn21
    Time-NLP
    1.0.1

《----------------------------------------------------------------------------------------------------------------------------------------------------
must: MySQL and should: MySQL or(저효율)
setExplain(true) 일치 순서
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();  
        boolQueryBuilder.must(QueryBuilders.wildcardQuery("name", "* *")).must(termQuery("foodType", " "));
SearchResponse response1 = EsUtils.getClient()
.prepareSearch("food")
.setTypes("_doc")
.setQuery(boolQueryBuilder)
.setFrom(Integer.parseInt("0"))
.setSize(Integer.parseInt("10"))
.setExplain(true)    
                .execute()    
                .actionGet();
for(SearchHit hit:response1.getHits().getHits()){
System.out.println(hit.getSourceAsString());

}

편집 -------------------------------
UpdateRequest updateRequest = new UpdateRequest();

updateRequest.index("food2");
updateRequest.type("_doc");
updateRequest.id("cAjpPmMBFth1dx0K4mIh");
updateRequest.doc(XContentFactory.jsonBuilder().startObject().field("name", " ").endObject());

client.update(updateRequest).get();

             
새로 만들기
 
UpdateRequest updateRequest = new UpdateRequest();

updateRequest.index("food2");
updateRequest.type("_doc");
updateRequest.id("cAjpPmMBFth1dx0K4mIh");
updateRequest.doc(XContentFactory.jsonBuilder().startObject().field("name", " ").endObject());

client.update(updateRequest).get();

                
삭제
 
EsUtils.delete(indexName, type, id);

좋은 웹페이지 즐겨찾기