本文整理汇总了Java中org.elasticsearch.indices.IndexMissingException类的典型用法代码示例。如果您正苦于以下问题:Java IndexMissingException类的具体用法?Java IndexMissingException怎么用?Java IndexMissingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndexMissingException类属于org.elasticsearch.indices包,在下文中一共展示了IndexMissingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteIndexByQuery
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
/**
* Delete index by query.
*
* @param uid
* the uid
*/
private void deleteIndexByQuery(String uid) {
try {
/** Don't handle plugin deployment documents, skip them */
if(!uid.endsWith(ElasticsearchIndexerConstants.WAR)){
Client client = _esConnector.getClient();
DeleteByQueryResponse response = client
.prepareDeleteByQuery(ElasticsearchIndexerConstants.ELASTIC_SEARCH_LIFERAY_INDEX)
.setQuery(QueryBuilders.queryString(ElasticsearchIndexerConstants.ELASTIC_SEARCH_QUERY_UID + uid))
.execute().actionGet();
if (_log.isDebugEnabled()) {
_log.debug("Document deleted successfully with Id:" + uid + " , Status:" + response.status());
}
}
} catch (NoNodeAvailableException noNodeEx) {
_log.error("No node available:" + noNodeEx.getDetailedMessage());
} catch (IndexMissingException indexMissingEx) {
_log.error("No index availabe:" + indexMissingEx.getDetailedMessage());
}
}
开发者ID:rivetlogic,项目名称:liferay-elasticsearch-integration,代码行数:28,代码来源:ElasticsearchIndexWriterImpl.java
示例2: readLastRunTimeFromCustomInfo
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
private TimeValue readLastRunTimeFromCustomInfo() throws IOException {
try {
GetResponse response = getClient().prepareGet("_river", riverContext.getRiverName(), ColumnRiverFlow.DOCUMENT).execute().actionGet();
if (response != null && response.isExists()) {
Map jdbcState = (Map) response.getSourceAsMap().get("jdbc");
if (jdbcState != null) {
Number lastRunTime = (Number) jdbcState.get(ColumnRiverFlow.LAST_RUN_TIME);
if (lastRunTime != null) {
return new TimeValue(lastRunTime.longValue());
}
} else {
throw new IOException("can't retrieve previously persisted state from _river/" + riverContext.getRiverName());
}
}
} catch (IndexMissingException e) {
logger.warn("river state missing: _river/{}/{}", riverContext.getRiverName(), "_custom");
}
return null;
}
示例3: waitForActiveRiver
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
public static void waitForActiveRiver(ClusterAdminClient client, String riverName, String riverType, int seconds) throws InterruptedException, IOException {
GetRiverStateRequest riverStateRequest = new GetRiverStateRequest()
.setRiverName(riverName)
.setRiverType(riverType);
GetRiverStateResponse riverStateResponse = client
.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
while (seconds-- > 0 && !isActive(riverName, riverStateResponse)) {
Thread.sleep(1000L);
try {
riverStateResponse = client.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
} catch (IndexMissingException e) {
//
}
}
if (seconds < 0) {
throw new IOException("timeout waiting for active river");
}
}
示例4: waitForInactiveRiver
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
public static void waitForInactiveRiver(ClusterAdminClient client, String riverName, String riverType, int seconds) throws InterruptedException, IOException {
GetRiverStateRequest riverStateRequest = new GetRiverStateRequest()
.setRiverName(riverName)
.setRiverType(riverType);
GetRiverStateResponse riverStateResponse = client
.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
while (seconds-- > 0 && isActive(riverName, riverStateResponse)) {
Thread.sleep(1000L);
try {
riverStateResponse = client.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
} catch (IndexMissingException e) {
//
}
}
if (seconds < 0) {
throw new IOException("timeout waiting for inactive river");
}
}
示例5: getIndexSize
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
private long getIndexSize(){
long indexSize = 0L;
final String indexName = indexLocationStrategy.getIndexInitialName();
try {
final IndicesStatsResponse statsResponse = esProvider.getClient()
.admin()
.indices()
.prepareStats(indexName)
.all()
.execute()
.actionGet();
final CommonStats indexStats = statsResponse.getIndex(indexName).getTotal();
indexSize = indexStats.getStore().getSizeInBytes();
} catch (IndexMissingException e) {
// if for some reason the index size does not exist,
// log an error and we can assume size is 0 as it doesn't exist
logger.error("Unable to get size for index {} due to IndexMissingException for app {}",
indexName, indexLocationStrategy.getApplicationScope().getApplication().getUuid());
}
return indexSize;
}
示例6: performFilterByOneField
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
/**
* Perform filter query into one ES index and type with one field and value. Be careful, this returns max 10 records!
*
* @param indexName to search in
* @param indexType to search
* @param fieldName name of field to search
* @param fieldValue value to search for
* @return SearchResponse.
*/
public SearchResponse performFilterByOneField(String indexName, String indexType, String fieldName, String fieldValue)
throws SearchIndexMissingException {
try {
SearchRequestBuilder searchBuilder = getClient().prepareSearch(indexName).setTypes(indexType).setSize(10);
searchBuilder.setPostFilter(FilterBuilders.queryFilter(QueryBuilders.matchQuery(fieldName, fieldValue)));
searchBuilder.setQuery(QueryBuilders.matchAllQuery());
final SearchResponse response = searchBuilder.execute().actionGet();
return response;
} catch (IndexMissingException e) {
log.log(Level.WARNING, e.getMessage());
throw new SearchIndexMissingException(e);
}
}
示例7: performQueryByOneFieldAnyValue
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
/**
* Perform filter query into one ES index and type to get records with any value stored in one field. Be careful, this
* method returns SCROLL response, so you have to use {@link #executeESScrollSearchNextRequest(SearchResponse)} to get
* real data and go over them as is common ES scroll mechanism.
*
* @param indexName to search in
* @param indexType to search
* @param fieldName name of field to search for any value in it
* @param sortByField name of field to sort results by
* @return Scroll SearchResponse
*/
public SearchResponse performQueryByOneFieldAnyValue(String indexName, String indexType, String fieldName,
String sortByField) throws SearchIndexMissingException {
try {
SearchRequestBuilder searchBuilder = getClient().prepareSearch(indexName).setTypes(indexType)
.setScroll(new TimeValue(ES_SCROLL_KEEPALIVE)).setSearchType(SearchType.SCAN).setSize(10);
searchBuilder.setPostFilter(FilterBuilders.notFilter(FilterBuilders.missingFilter(fieldName)));
searchBuilder.setQuery(QueryBuilders.matchAllQuery());
searchBuilder.addSort(sortByField, SortOrder.ASC);
final SearchResponse response = searchBuilder.execute().actionGet();
return response;
} catch (IndexMissingException e) {
log.log(Level.WARNING, e.getMessage());
throw new SearchIndexMissingException(e);
}
}
示例8: feed_errorhandling_3
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
@Test
public void feed_errorhandling_3() throws IOException, URISyntaxException {
FeedRestService tested = getTested();
// case - error handling for index not found exception
{
Mockito.reset(tested.querySettingsParser, tested.searchService);
UriInfo uriInfo = Mockito.mock(UriInfo.class);
MultivaluedMap<String, String> qp = new MultivaluedMapImpl<String, String>();
Mockito.when(uriInfo.getQueryParameters()).thenReturn(qp);
QuerySettings qs = new QuerySettings();
Mockito.when(tested.querySettingsParser.parseUriParams(qp)).thenReturn(qs);
Mockito.when(
tested.searchService.performSearch(Mockito.eq(qs), Mockito.notNull(String.class),
Mockito.eq(StatsRecordType.FEED))).thenThrow(new IndexMissingException(null));
Object response = tested.feed(uriInfo);
TestUtils.assertResponseStatus(response, Status.NOT_FOUND);
}
}
示例9: purge_orphan_metadatas
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
/**
* Delete orphan (w/o pathindex) metadatas elements
*/
public static void purge_orphan_metadatas(boolean let_clean_empty_and_removed_storages) throws Exception {
try {
ElastisearchCrawlerReader reader = Elasticsearch.createCrawlerReader();
reader.setIndices(ES_INDEX);
reader.setQuery(QueryBuilders.matchAllQuery());
ElasticsearchBulkOperation es_bulk = Elasticsearch.prepareBulk();
HitPurge hit_purge = new HitPurge(es_bulk, let_clean_empty_and_removed_storages);
reader.allReader(hit_purge);
es_bulk.terminateBulk();
Loggers.Metadata.info("Start cleaning rendered elements");
RenderedFile.purge_orphan_metadatas_files();
} catch (IndexMissingException ime) {
Loggers.Metadata.warn("Can't purge orphan metadatas: " + ES_INDEX + " index is not present", ime);
} catch (SearchPhaseExecutionException e) {
Loggers.Metadata.warn("Can't purge orphan metadatas", e);
}
}
示例10: isMappingExist
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
/**
* Check if a mapping already exists in an index
* @param index Index name
* @param type Mapping name
* @return true if mapping exists
*/
private boolean isMappingExist(String index, String type) {
IndexMetaData imd = null;
try {
ClusterState cs = client.admin().cluster().prepareState().setFilterIndices(index).execute().actionGet().getState();
imd = cs.getMetaData().index(index);
} catch (IndexMissingException e) {
// If there is no index, there is no mapping either
}
if (imd == null) return false;
MappingMetaData mdd = imd.mapping(type);
if (mdd != null) return true;
return false;
}
示例11: analyze
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
/**
* 分词-无法分词则返回空集合
*
* @param analyzer
* @param str
* @return
*/
public static List<String> analyze(String analyzer, String str) {
AnalyzeResponse ar = null;
try {
AnalyzeRequest request = new AnalyzeRequest(str).analyzer(analyzer).index(
getCurrentValidIndex());
ar = ESClient.getClient().admin().indices().analyze(request).actionGet();
} catch (IndexMissingException e) {
if (!reLoad) {
synchronized (AnalyzeHelper.class) {
if (!reLoad) {
reLoad = true;
}
}
}
return analyze(analyzer, str);
}
if (ar == null || ar.getTokens() == null || ar.getTokens().size() < 1) {
return Lists.newArrayList();
}
List<String> analyzeTokens = Lists.newArrayList();
for (AnalyzeToken at : ar.getTokens()) {
analyzeTokens.add(at.getTerm());
}
return analyzeTokens;
}
示例12: refresh
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
private static boolean refresh(String index) {
try {
AdminClient adminClient = client.getClient().admin();
RefreshRequestBuilder refreshRequestBuilder = adminClient.indices().prepareRefresh(index);
adminClient.indices().refresh(refreshRequestBuilder.request()).actionGet();
return true;
} catch (IndexMissingException t) {
// Ignore, as means that no traces have
// been stored yet
if (msgLog.isTraceEnabled()) {
msgLog.tracef("Index [%s] not found, unable to proceed.", index);
}
return false;
}
}
示例13: deleteIndices
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
@AfterMethod
public void deleteIndices() {
logger.info("deleting index {}", INDEX);
try {
client("1").admin().indices().delete(new DeleteIndexRequest().indices(INDEX)).actionGet();
} catch (IndexMissingException e) {
// ignore
}
logger.info("index {} deleted", INDEX);
closeAllNodes();
}
示例14: deleteESIndex
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
private static void deleteESIndex() {
try {
elasticClient.admin().indices().delete(new DeleteIndexRequest(KEYSPACE)).actionGet();
} catch (IndexMissingException indexEception) {
logger.info("Trying to delete a non-existing index " + KEYSPACE);
}
}
示例15: waitForRiverEnabled
import org.elasticsearch.indices.IndexMissingException; //导入依赖的package包/类
public static void waitForRiverEnabled(ClusterAdminClient client, String riverName, String riverType, int seconds) throws InterruptedException, IOException {
GetRiverStateRequest riverStateRequest = new GetRiverStateRequest()
.setRiverName(riverName)
.setRiverType(riverType);
GetRiverStateResponse riverStateResponse = client
.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
while (seconds-- > 0 && !isEnabled(riverName, riverStateResponse)) {
Thread.sleep(1000L);
try {
riverStateResponse = client.execute(GetRiverStateAction.INSTANCE, riverStateRequest).actionGet();
} catch (IndexMissingException e) {
// ignore
}
}
}