當前位置: 首頁>>代碼示例>>Java>>正文


Java Requests.CONTENT_TYPE屬性代碼示例

本文整理匯總了Java中org.elasticsearch.client.Requests.CONTENT_TYPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Requests.CONTENT_TYPE屬性的具體用法?Java Requests.CONTENT_TYPE怎麽用?Java Requests.CONTENT_TYPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.elasticsearch.client.Requests的用法示例。


在下文中一共展示了Requests.CONTENT_TYPE屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: should_percolate_with_highlight

@Test
public void should_percolate_with_highlight() throws IOException, ExecutionException, InterruptedException {
    createMapping();

    Requests.CONTENT_TYPE = XContentType.JSON;

    XContentBuilder query = XContentFactory.jsonBuilder()
            .startObject()
            .field("query", matchQuery("message", "bonsai tree"))
            .endObject();
    transportClient.index(Requests.indexRequest(THE_INDEX).type(".percolator").source(query)).actionGet();

    refresh();

    PercolateSourceBuilder.DocBuilder doc = new PercolateSourceBuilder.DocBuilder()
            .setDoc(XContentFactory.jsonBuilder().startObject().field("message", "A new bonsai tree in the office").endObject());
    PercolateRequest request = new PercolateRequest().indices(THE_INDEX).documentType("my-type")
            .source(new PercolateSourceBuilder().setTrackScores(true).setDoc(doc)
                    .setHighlightBuilder(new HighlightBuilder()
                            .field("message").preTags("<foo>").postTags("<bar>")).setSize(5));

    PercolateResponse response = httpClient.percolate(request).get();

    Assertions.assertThat(response.getTotal()).isEqualTo(1);
    Assertions.assertThat(response.getMatches()).hasSize(1);

    Assertions.assertThat(response.getMatches()).hasSize(1);
    Map<String, Highlight> highlight = response.getMatches().getMatches().get(0).getHighlights();
    Assertions.assertThat(highlight).isNotNull().hasSize(1);
    Assertions.assertThat(highlight.get("message").getValue()).contains("<foo>").contains("<bar>").contains("bonsai").contains("tree");
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:31,代碼來源:PercolateActionHandlerTest.java

示例2: should_percolate_with_highlight

@Test
public void should_percolate_with_highlight() throws IOException, ExecutionException, InterruptedException {
    createMapping();

    Requests.CONTENT_TYPE = XContentType.JSON;

    XContentBuilder query = XContentFactory.jsonBuilder()
            .startObject()
            .field("query", matchQuery("message", "bonsai tree"))
            .endObject();
    transportClient.index(Requests.indexRequest(THE_INDEX).type(".percolator").source(query)).actionGet();

    refresh();

    PercolateSourceBuilder.DocBuilder doc = new PercolateSourceBuilder.DocBuilder()
            .setDoc(XContentFactory.jsonBuilder().startObject().field("message", "A new bonsai tree in the office").endObject());
    PercolateRequest request = new PercolateRequest().indices(THE_INDEX).documentType("my-type")
            .source(new PercolateSourceBuilder().setTrackScores(true).setDoc(doc)
                    .setHighlightBuilder(new HighlightBuilder()
                            .field("message").preTags("<foo>").postTags("<bar>")).setSize(5));

    MultiPercolateRequest multiPercolateRequest = new MultiPercolateRequest().add(request);

    MultiPercolateResponse response = httpClient.multiPercolate(multiPercolateRequest).get();

    Assertions.assertThat(response.all()).hasSize(1);
    Assertions.assertThat(response.errors()).hasSize(0);

    PercolateResponse percolateResponse = response.percolated().get(0);
    Assertions.assertThat(percolateResponse.getTotal()).isEqualTo(1);
    Assertions.assertThat(percolateResponse.getMatches()).hasSize(1);

    Assertions.assertThat(percolateResponse.getMatches()).hasSize(1);
    Map<String, Highlight> highlight = percolateResponse.getMatches().getMatches().get(0).getHighlights();
    Assertions.assertThat(highlight).isNotNull().hasSize(1);
    Assertions.assertThat(highlight.get("message").getValue()).contains("<foo>").contains("<bar>").contains("bonsai").contains("tree");
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:37,代碼來源:MultiPercolateActionHandlerTest.java

示例3: setContentType

@BeforeClass
public static void setContentType() throws Exception {
    Requests.CONTENT_TYPE = randomFrom(XContentType.values());
    Requests.INDEX_CONTENT_TYPE = randomFrom(XContentType.values());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:ESTestCase.java

示例4: restoreContentType

@AfterClass
public static void restoreContentType() {
    Requests.CONTENT_TYPE = XContentType.SMILE;
    Requests.INDEX_CONTENT_TYPE = XContentType.JSON;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:ESTestCase.java

示例5: ToXContentToBytes

protected ToXContentToBytes() {
    this.defaultType = Requests.CONTENT_TYPE;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:3,代碼來源:ToXContentToBytes.java

示例6: save_request_content_type

@Before
public void save_request_content_type() {
    // this client only uses JSON, so set the content type used by ES on request generation, but also clean up stuff afterwards
    initialContentType = Requests.CONTENT_TYPE;
    Requests.CONTENT_TYPE = JSON;
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:6,代碼來源:AbstractTest.java

示例7: restore_request_content_type

@After
public void restore_request_content_type() {
    Requests.CONTENT_TYPE = initialContentType;
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:4,代碼來源:AbstractTest.java


注:本文中的org.elasticsearch.client.Requests.CONTENT_TYPE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。