当前位置: 首页>>代码示例>>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;未经允许,请勿转载。