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


Java RefreshRequest類代碼示例

本文整理匯總了Java中org.elasticsearch.action.admin.indices.refresh.RefreshRequest的典型用法代碼示例。如果您正苦於以下問題:Java RefreshRequest類的具體用法?Java RefreshRequest怎麽用?Java RefreshRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: refreshAndFinish

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
/**
 * Start terminating a request that finished non-catastrophically by refreshing the modified indices and then proceeding to
 * {@link #finishHim(Exception, List, List, boolean)}.
 */
void refreshAndFinish(List<Failure> indexingFailures, List<SearchFailure> searchFailures, boolean timedOut) {
    if (task.isCancelled() || false == mainRequest.isRefresh() || destinationIndices.isEmpty()) {
        finishHim(null, indexingFailures, searchFailures, timedOut);
        return;
    }
    RefreshRequest refresh = new RefreshRequest();
    refresh.indices(destinationIndices.toArray(new String[destinationIndices.size()]));
    client.admin().indices().refresh(refresh, new ActionListener<RefreshResponse>() {
        @Override
        public void onResponse(RefreshResponse response) {
            finishHim(null, indexingFailures, searchFailures, timedOut);
        }

        @Override
        public void onFailure(Exception e) {
            finishHim(e);
        }
    });
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:24,代碼來源:AbstractAsyncBulkByScrollAction.java

示例2: commit

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Override
public void commit() {
	if (this.client != null) {
		this.flushIndex(true);
		this.client.admin().indices()
				.refresh(new RefreshRequest(this.indexName)).actionGet();

		// enable index auto refresh
		ImmutableSettings.Builder indexSettings = ImmutableSettings
				.settingsBuilder();
		indexSettings.put("refresh_interval", 1);
		this.client.admin().indices().prepareUpdateSettings(this.indexName)
				.setSettings(indexSettings).execute().actionGet();

		this.client.admin().indices().prepareOptimize(this.indexName)
				.setMaxNumSegments(5).execute().actionGet();
	}
}
 
開發者ID:enricopal,項目名稱:STEM,代碼行數:19,代碼來源:ElasticSearchDatabase.java

示例3: deleteDocById

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
/**
 * 刪除文檔
 * 
 * @param id
 */
public boolean deleteDocById(String docId) {
    try {
        // 刪除
        DeleteResponse resp = ESClient.getClient()
                .prepareDelete(this.currentIndexName, this.indexType.getTypeName(), docId)
                .setOperationThreaded(false).execute().actionGet();
        // 刷新
        ESClient.getClient().admin().indices()
                .refresh(new RefreshRequest(this.currentIndexName)).actionGet();
        if (resp.isFound()) {
            log.warn("delete index sunccess,indexname:{},type:{},delete {} items",
                    this.indexType.getIndexName(), this.indexType.getTypeName(), 1);
            return resp.isFound();
        }
    } catch (Exception e) {
        log.error("delete Doc fail,indexname:{},type:{}", this.indexType.getIndexName(),
                this.indexType.getTypeName());
    }
    return false;
}
 
開發者ID:hailin0,項目名稱:es-service-parent,代碼行數:26,代碼來源:IndexTransaction.java

示例4: testMetadata

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testMetadata() throws Exception{
	createMetadataDocument();
	ae.process(jCas);

	//Call refresh to force ES to write buffer
	client.admin().indices().refresh(new RefreshRequest("baleen_index")).actionGet();

	assertEquals(new Long(1), getCount());

	SearchHit result = client.search(new SearchRequest()).actionGet().getHits().hits()[0];
	List<String> pids = (List<String>) result.getSource().get("publishedId");
	assertEquals("id_1", pids.get(0));
	assertEquals("id_2", pids.get(1));

	Map<String, Object> metadataMap = (Map<String, Object>) result.getSource().get("metadata");

	assertEquals("D3", metadataMap.get("sourceAndInformationGrading"));

	assertEquals("test_value", metadataMap.get("test_key"));
	assertEquals("Test Title", metadataMap.get("documentTitle"));
	assertEquals("ENG|WAL|SCO", metadataMap.get("countryInfo"));
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:25,代碼來源:ElasticsearchTestBase.java

示例5: testReindexEntities

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Test
public void testReindexEntities() throws Exception{
	createEntitiesDocument();
	ae.process(jCas);
	ae.process(jCas);
	
	// Change the last document so we can check its been updated
	getDocumentAnnotation(jCas).setDocumentClassification("TEST");
	ae.process(jCas);

	//Call refresh to force ES to write buffer
	client.admin().indices().refresh(new RefreshRequest("baleen_index")).actionGet();

	assertEquals(new Long(1), getCount());
	SearchHit result = client.search(new SearchRequest()).actionGet().getHits().hits()[0];
	
	// This checks the last document is tone we are getting
	assertEquals("TEST", result.getSource().get("classification"));
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:20,代碼來源:ElasticsearchTestBase.java

示例6: testNestedEntities

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Test
public void testNestedEntities() throws Exception{
	createEntitiesDocument();
	ae.process(jCas);
	
	createEntitiesDocument2();
	ae.process(jCas);
	
	//Call refresh to force ES to write buffer
	client.admin().indices().refresh(new RefreshRequest("baleen_index")).actionGet();

	assertEquals(new Long(2), getCount());
	
	SearchRequestBuilder srb = client.prepareSearch("baleen_index").setQuery(
		QueryBuilders.nestedQuery("entities", QueryBuilders.boolQuery()
				.must(QueryBuilders.matchQuery("entities.type", "Location"))
				.must(QueryBuilders.matchQuery("entities.value", "London")))
	);
	
	SearchHits results = client.search(srb.request()).actionGet().getHits();
	assertEquals(1, results.getTotalHits());
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:23,代碼來源:ElasticsearchTestBase.java

示例7: getAllIndexedDocs

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
public List<Map<String, Object>> getAllIndexedDocs(String index, String sourceType,
      String subMessage) throws IOException {
    getClient().admin().indices().refresh(new RefreshRequest());
    SearchResponse response = getClient().prepareSearch(index)
        .setTypes(sourceType)
//                .setSource("message") ??
        .setFrom(0)
        .setSize(1000)
        .execute().actionGet();
    List<Map<String, Object>> ret = new ArrayList<Map<String, Object>>();
    for (SearchHit hit : response.getHits()) {
      Object o = null;
      if (subMessage == null) {
        o = hit.getSource();
      } else {
        o = hit.getSource().get(subMessage);
      }
      ret.add((Map<String, Object>) (o));
    }
    return ret;
  }
 
開發者ID:apache,項目名稱:metron,代碼行數:22,代碼來源:ElasticSearchComponent.java

示例8: should_refresh_index

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Test
public void should_refresh_index() throws Exception {
    transportClient.admin().indices()
            .updateSettings(Requests.updateSettingsRequest(THE_INDEX)
                    .settings(Collections.singletonMap("refresh_interval", MAX_VALUE)));

    index(THE_INDEX, THE_TYPE, THE_ID, "foo", "bar");

    SearchResponse searchResponse = transportClient.search(new SearchRequest(THE_INDEX).source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()))).actionGet();
    Assertions.assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);

    RefreshResponse refreshResponse = httpClient.admin().indices().refresh(new RefreshRequest(THE_INDEX)).get();

    NumShards actualNumShards = getNumShards(THE_INDEX);
    Assertions.assertThat(refreshResponse.getShards().getTotal()).isEqualTo(actualNumShards.totalNumShards);

    searchResponse = transportClient.search(new SearchRequest(THE_INDEX).source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()))).actionGet();
    Assertions.assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:20,代碼來源:RefreshActionHandlerTest.java

示例9: testBigAndFatResponse

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Test
public void testBigAndFatResponse() throws Exception {
    Client client = client("1");
    for (int i = 0; i < 10000; i++) {
        client.index(new IndexRequest("test", "test", Integer.toString(i))
                .source("{\"random\":\""+randomString(32)+ " " + randomString(32) + "\"}")).actionGet();
    }
    client.admin().indices().refresh(new RefreshRequest("test")).actionGet();
    InetSocketTransportAddress httpAddress = findHttpAddress(client);
    if (httpAddress == null) {
        throw new IllegalArgumentException("no HTTP address found");
    }
    URL base = new URL("http://" + httpAddress.getHost() + ":" + httpAddress.getPort());
    URL url = new URL(base, "/test/test/_search?xml&pretty&size=10000");
    BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
    int count = 0;
    String line;
    while ((line = reader.readLine()) != null) {
        count += line.length();
    }
    assertTrue(count >= 2309156);
    reader.close();
    client.admin().indices().delete(new DeleteIndexRequest("test"));
}
 
開發者ID:jprante,項目名稱:elasticsearch-xml,代碼行數:25,代碼來源:XmlPluginTest.java

示例10: testAttachments

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Test
public void testAttachments() throws Exception{

        Map<String, Object> settings = settings("/river-imap-attachments.json");

	final Properties props = new Properties();
	final String user = XContentMapValues.nodeStringValue(settings.get("user"), null);
	final String password = XContentMapValues.nodeStringValue(settings.get("password"), null);

	for (final Map.Entry<String, Object> entry : settings.entrySet()) {

		if (entry != null && entry.getKey().startsWith("mail.")) {
			props.setProperty(entry.getKey(), String.valueOf(entry.getValue()));
		}
	}

	registerRiver("imap_river", "river-imap-attachments.json");

	final Session session = Session.getInstance(props);
	final Store store = session.getStore();
	store.connect(user, password);
	checkStoreForTestConnection(store);
	final Folder inbox = store.getFolder("INBOX");
	inbox.open(Folder.READ_WRITE);



	final MimeMessage message = new MimeMessage(session);
	message.setFrom(new InternetAddress(EMAIL_TO));
	message.addRecipient(Message.RecipientType.TO, new InternetAddress(EMAIL_USER_ADDRESS));
	message.setSubject(EMAIL_SUBJECT + "::attachment test");
	message.setSentDate(new Date());

	BodyPart bp = new MimeBodyPart();
	bp.setText("Text");
	Multipart mp = new MimeMultipart();
	mp.addBodyPart(bp);

	bp = new MimeBodyPart();
	DataSource ds = new ByteArrayDataSource(this.getClass().getResourceAsStream("/httpclient-tutorial.pdf"), AttachmentMapperTest.APPLICATION_PDF);
	bp.setDataHandler(new DataHandler(ds));
	bp.setFileName("httpclient-tutorial.pdf");
	mp.addBodyPart(bp);
	message.setContent(mp);

	inbox.appendMessages(new Message[]{message});
	IMAPUtils.close(inbox);
	IMAPUtils.close(store);

	//let the river index
	Thread.sleep(20*1000);

	esSetup.client().admin().indices().refresh(new RefreshRequest()).actionGet();

	SearchResponse searchResponse =  esSetup.client().prepareSearch("imapriverdata").setTypes("mail").execute().actionGet();
	Assert.assertEquals(1, searchResponse.getHits().totalHits());
               
	//BASE64 content httpclient-tutorial.pdf
	Assert.assertTrue(searchResponse.getHits().hits()[0].getSourceAsString().contains(AttachmentMapperTest.PDF_BASE64_DETECTION));

	searchResponse =  esSetup.client().prepareSearch("imapriverdata").addFields("*").setTypes("mail").setQuery(QueryBuilders.matchPhraseQuery("attachments.content.content", PDF_CONTENT_TO_SEARCH)).execute().actionGet();
	Assert.assertEquals(1, searchResponse.getHits().totalHits());

	Assert.assertEquals(1, searchResponse.getHits().hits()[0].field("attachments.content.content").getValues().size());
	Assert.assertEquals("HttpClient Tutorial", searchResponse.getHits().hits()[0].field("attachments.content.title").getValue().toString());
	Assert.assertEquals("application/pdf", searchResponse.getHits().hits()[0].field("attachments.content.content_type").getValue().toString());
	Assert.assertTrue(searchResponse.getHits().hits()[0].field("attachments.content.content").getValue().toString().contains(PDF_CONTENT_TO_SEARCH));

}
 
開發者ID:salyh,項目名稱:elasticsearch-imap,代碼行數:70,代碼來源:AttachmentMapperTest.java

示例11: getCount

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
protected long getCount(final List<String> indices, final String type) {
    logger.debug("getCount() for index {} and type", indices, type);
    
    esSetup.client().admin().indices().refresh(new RefreshRequest()).actionGet();

    long count = 0;
    
    for (Iterator<String> iterator = indices.iterator(); iterator.hasNext();) {
        String index = (String) iterator.next();
         long lcount = esSetup.client().count(new CountRequest(index).types(type)).actionGet().getCount();
         logger.debug("Count for index {} (type {}) is {}", index, type, lcount);
         count += lcount;
    }

    return count;
}
 
開發者ID:salyh,項目名稱:elasticsearch-imap,代碼行數:17,代碼來源:AbstractIMAPRiverUnitTest.java

示例12: testNodeBasedClientCanConnectToES

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Test
public void testNodeBasedClientCanConnectToES() {
    System.setProperty(ConfigurationConstants.PROPNAME_ES_CLIENT_TYPE, "node");
    Configuration config = new SystemPropertiesConfiguration();

    esServer = new ElasticSearchServer(clusterName,false);
    assertTrue("Unable to start in memory elastic search", esServer.isSetup());

    try {
        ElasticSearchClientFactory factory = clientFactoryCreator.getElasticSearchClientConnectionFactory(config);
        Client c = factory.getClient();
        assertEquals(config.getStorageClusterName(), c.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().getClusterName().value());

        assertNotNull(c.index(new IndexRequest("test", "test").source("name", "a")).actionGet().getId());
        c.admin().indices().refresh(new RefreshRequest("test").force(true)).actionGet();

        assertEquals(1, c.admin().indices().stats(new IndicesStatsRequest().indices("test")).actionGet().getTotal().docs.getCount());
    } catch(Exception e) {
        e.printStackTrace();
        fail("Unable to connect to elasticsearch: " + e.getMessage());
    }
}
 
開發者ID:tootedom,項目名稱:related,代碼行數:23,代碼來源:NodeOrTransportBasedElasticSearchClientFactoryCreatorTest.java

示例13: prepareRequest

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    RefreshRequest refreshRequest = new RefreshRequest(Strings.splitStringByCommaToArray(request.param("index")));
    refreshRequest.indicesOptions(IndicesOptions.fromRequest(request, refreshRequest.indicesOptions()));
    return channel -> client.admin().indices().refresh(refreshRequest, new RestBuilderListener<RefreshResponse>(channel) {
        @Override
        public RestResponse buildResponse(RefreshResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(response.getStatus(), builder);
        }
    });
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:15,代碼來源:RestRefreshAction.java

示例14: setupSuiteScopeCluster

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Override
public void setupSuiteScopeCluster() throws Exception {
    assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(
            "book", "author", "type=keyword", "name", "type=keyword", "genre",
            "type=keyword", "price", "type=float"));
    createIndex("idx_unmapped");
    // idx_unmapped_author is same as main index but missing author field
    assertAcked(prepareCreate("idx_unmapped_author").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0)
            .addMapping("book", "name", "type=keyword", "genre", "type=keyword", "price",
                    "type=float"));

    ensureGreen();
    String data[] = {
            // "id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s",
            "0553573403,book,A Game of Thrones,7.99,true,George R.R. Martin,A Song of Ice and Fire,1,fantasy",
            "0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,A Song of Ice and Fire,2,fantasy",
            "055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,A Song of Ice and Fire,3,fantasy",
            "0553293354,book,Foundation,17.99,true,Isaac Asimov,Foundation Novels,1,scifi",
            "0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy",
            "0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi",
            "0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy",
            "0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy",
            "0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy",
            "080508049X,book,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy"

        };

    for (int i = 0; i < data.length; i++) {
        String[] parts = data[i].split(",");
        client().prepareIndex("test", "book", "" + i)
                .setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3])).get();
        client().prepareIndex("idx_unmapped_author", "book", "" + i)
                .setSource("name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3])).get();
    }
    client().admin().indices().refresh(new RefreshRequest("test")).get();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:37,代碼來源:DiversifiedSamplerIT.java

示例15: setupSuiteScopeCluster

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; //導入依賴的package包/類
@Override
public void setupSuiteScopeCluster() throws Exception {
    assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(
            "book", "author", "type=keyword", "name", "type=text", "genre",
            "type=keyword", "price", "type=float"));
    createIndex("idx_unmapped");
    // idx_unmapped_author is same as main index but missing author field
    assertAcked(prepareCreate("idx_unmapped_author").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0)
            .addMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float"));

    ensureGreen();
    String data[] = {
            // "id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s",
            "0553573403,book,A Game of Thrones,7.99,true,George R.R. Martin,A Song of Ice and Fire,1,fantasy",
            "0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,A Song of Ice and Fire,2,fantasy",
            "055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,A Song of Ice and Fire,3,fantasy",
            "0553293354,book,Foundation,17.99,true,Isaac Asimov,Foundation Novels,1,scifi",
            "0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy",
            "0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi",
            "0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy",
            "0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy",
            "0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy",
            "080508049X,book,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy"

        };

    for (int i = 0; i < data.length; i++) {
        String[] parts = data[i].split(",");
        client().prepareIndex("test", "book", "" + i).setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price",Float.parseFloat(parts[3])).get();
        client().prepareIndex("idx_unmapped_author", "book", "" + i).setSource("name", parts[2], "genre", parts[8],"price",Float.parseFloat(parts[3])).get();
    }
    client().admin().indices().refresh(new RefreshRequest("test")).get();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:34,代碼來源:SamplerIT.java


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