当前位置: 首页>>代码示例>>Java>>正文


Java Get类代码示例

本文整理汇总了Java中io.searchbox.core.Get的典型用法代码示例。如果您正苦于以下问题:Java Get类的具体用法?Java Get怎么用?Java Get使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Get类属于io.searchbox.core包,在下文中一共展示了Get类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import io.searchbox.core.Get; //导入依赖的package包/类
@Override
protected Profile doInBackground(String... parameters){
    verifySettings();

    Profile profile = null;

    Get get = new Get.Builder(appESIndex, parameters[0]).type("profile").build();

    try {
        JestResult result = client.execute(get);
        if (result.isSucceeded()) {
            profile = (result.getSourceAsObject(Profile.class));
        }
    }
    catch (Exception e){
        Log.i("Error", "ElasticSearch failed to find profile");
    }
    return profile;
}
 
开发者ID:CMPUT301F17T09,项目名称:GoalsAndHabits,代码行数:20,代码来源:ElasticSearchController.java

示例2: doInBackground

import io.searchbox.core.Get; //导入依赖的package包/类
@Override
protected Request doInBackground(String... params) {
    verifySettings();

    Get get = new Get.Builder("cmput301f16t01", params[0])
            .type( "request" ).build();

    try {
        JestResult result = client.execute(get);
        if (result.isSucceeded()) {
            return result.getSourceAsObject(Request.class);
        } else {
            throw new IllegalArgumentException( result.getErrorMessage() );
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new IllegalArgumentException();
    }
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:20,代码来源:ElasticRequestController.java

示例3: executeGet

import io.searchbox.core.Get; //导入依赖的package包/类
protected final Tuple<JestResult, HttpResponse> executeGet(final String index, final String type, final String id,
        final boolean mustBeSuccesfull, final boolean connectFromLocalhost) throws Exception {

    client = getJestClient(getServerUri(connectFromLocalhost), username, password);

    final Tuple<JestResult, HttpResponse> restu = client.executeE(new Get.Builder(index, id).type(type).refresh(true)
            .setHeader(headers).build());

    final JestResult res = restu.v1();

    if (mustBeSuccesfull) {
        if (res.getErrorMessage() != null) {
            log.error("Get operation result: {}", res.getErrorMessage());
        }
        Assert.assertTrue("Error msg: " + res.getErrorMessage() + res.getJsonString(), res.isSucceeded());
    } else {
        log.debug("Get operation result fails as expected");
        Assert.assertTrue(!res.isSucceeded());
    }
    return restu;
}
 
开发者ID:petalmd,项目名称:armor,代码行数:22,代码来源:AbstractUnitTest.java

示例4: getJsonById

import io.searchbox.core.Get; //导入依赖的package包/类
public String getJsonById(String id) throws IOException {
  Flush flush = new Flush.Builder().build();
  jestHttpClient.execute(flush);

  long start = System.currentTimeMillis();
  Get get = new Get.Builder(_esIndexName, id).build();
  JestResult result = null;
  try {
    result = jestHttpClient.execute(get);
  } catch (IOException e) {
    e.printStackTrace();
  }
  long end = System.currentTimeMillis();
  LOG.info("->> GetJsonByID: search time --> " + (end - start) + " milliseconds");
  return result.getJsonString();
}
 
开发者ID:faustineinsun,项目名称:WiseCrowdRec,代码行数:17,代码来源:JestElasticsearchManipulator.java

示例5: checkCacheVersion

import io.searchbox.core.Get; //导入依赖的package包/类
/**
 * Checks the ES store to see if the 'dataVersion' entry has been updated with a newer
 * version #.  If it has, then we need to invalidate our cache.
 */
protected void checkCacheVersion() {
    // Be very aggressive in invalidating the cache.
    boolean invalidate = true;
    try {
        Get get = new Get.Builder(getDefaultIndexName(), "instance").type("dataVersion").build(); //$NON-NLS-1$ //$NON-NLS-2$
        JestResult result = getClient().execute(get);
        if (result.isSucceeded()) {
            String latestDV = result.getJsonObject().get("_version").getAsString(); //$NON-NLS-1$
            if (latestDV != null && dataVersion != null && latestDV.equals(dataVersion)) {
                invalidate = false;
            } else {
                dataVersion = latestDV;
            }
        }
    } catch (IOException e) {
        // TODO need to use the gateway logger to log this!
        e.printStackTrace();
    }
    if (invalidate) {
        invalidateCache();
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:27,代码来源:PollCachingESRegistry.java

示例6: validateContract

import io.searchbox.core.Get; //导入依赖的package包/类
/**
 * Ensures that the api referenced by the Contract at the head of
 * the iterator actually exists (is published).
 * @param contract
 * @param apiMap
 */
private void validateContract(final Contract contract)
        throws RegistrationException {
    final String id = getApiId(contract);

    try {
        Get get = new Get.Builder(getIndexName(), id).type("api").build(); //$NON-NLS-1$
        JestResult result = getClient().execute(get);
        if (!result.isSucceeded()) {
            String apiId = contract.getApiId();
            String orgId = contract.getApiOrgId();
            throw new ApiNotFoundException(Messages.i18n.format("ESRegistry.ApiNotFoundInOrg", apiId, orgId));  //$NON-NLS-1$
        }
    } catch (IOException e) {
        throw new RegistrationException(Messages.i18n.format("ESRegistry.ErrorValidatingClient"), e); //$NON-NLS-1$
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:23,代码来源:ESRegistry.java

示例7: get

import io.searchbox.core.Get; //导入依赖的package包/类
@Override
public IEsItem get(IEsItem doc) throws Exception {
	Get.Builder builder = new Get.Builder(doc.getIndex(), doc.getId());
	if (doc.getType() != null) {
		builder.type(doc.getType());
	}
	DocumentResult result = _exec(builder.build());
	if (result != null) {
		return result.getSourceAsObject(doc.getClass());
	}
	return null;
}
 
开发者ID:DataSays,项目名称:wES,代码行数:13,代码来源:JestClient.java

示例8: doInBackground

import io.searchbox.core.Get; //导入依赖的package包/类
@Override
protected User doInBackground(String... search_parameters) {
    verifySettings();
    Get get = new Get.Builder(INDEX, search_parameters[0]).type(USER).id(search_parameters[0]).build();

    User user = null;
    try {
        JestResult result = client.execute(get);
        user = result.getSourceAsObject(User.class);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return user;
}
 
开发者ID:CMPUT301F16T02,项目名称:Dryver,代码行数:15,代码来源:ElasticSearchController.java

示例9: isValidDocumentIndex

import io.searchbox.core.Get; //导入依赖的package包/类
@Override
public boolean isValidDocumentIndex(String indexName, String documentType, String id, String json)
{
    Get get =  new Get.Builder(indexName,  id).type(documentType).build();
    JestResult jestResult = jestClientHelper.executeAction(get);

    // Retrieve the JSON string from the get response
    final String jsonStringFromIndex = jestResult.getSourceAsString();

    // Return true if the json from the index is not null or empty and the json from the index matches the object from the database
    return StringUtils.isNotEmpty(jsonStringFromIndex) && jsonStringFromIndex.equals(json);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:13,代码来源:IndexFunctionsDaoImpl.java

示例10: get

import io.searchbox.core.Get; //导入依赖的package包/类
public <T extends EsEntity<?>> Optional<T> get(Class<T> cls, String id) {
    DocumentResult result = execute(
            new Get.Builder(EsNameHelper.index(cls), id).type(EsNameHelper.type(cls)).build());
    if (result.isSucceeded()) {
        T entity = result.getSourceAsObject(cls);
        entity.setId(id);
        entity.setVersion(result.getJsonObject().get("_version").getAsLong());
        return Optional.of(entity);
    }
    return Optional.empty();
}
 
开发者ID:ruediste,项目名称:rise,代码行数:12,代码来源:EsHelper.java

示例11: getEntity

import io.searchbox.core.Get; //导入依赖的package包/类
/**
 * Gets an entity.  Callers must unmarshal the resulting map.
 * @param type
 * @param id
 * @throws StorageException
 */
private Map<String, Object> getEntity(String type, String id) throws StorageException {
    try {
        JestResult response = esClient.execute(new Get.Builder(getIndexName(), id).type(type).build());
        if (!response.isSucceeded()) {
            return null;
        }
        return response.getSourceAsObject(Map.class);
    } catch (Exception e) {
        throw new StorageException(e);
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:18,代码来源:EsStorage.java

示例12: accept

import io.searchbox.core.Get; //导入依赖的package包/类
/**
 * @see io.apiman.gateway.engine.components.IRateLimiterComponent#accept(java.lang.String, io.apiman.gateway.engine.rates.RateBucketPeriod, long, long, io.apiman.gateway.engine.async.IAsyncResultHandler)
 */
@Override
public void accept(final String bucketId, final RateBucketPeriod period, final long limit,
        final long increment, final IAsyncResultHandler<RateLimitResponse> handler) {
    final String id = id(bucketId);

    try {
        Get get = new Get.Builder(getIndexName(), id).type("rateBucket").build(); //$NON-NLS-1$
        JestResult result = getClient().execute(get);
        RateLimiterBucket bucket;
        long version;
        if (result.isSucceeded()) {
            // use the existing bucket
            version = result.getJsonObject().get("_version").getAsLong(); //$NON-NLS-1$
            bucket = result.getSourceAsObject(RateLimiterBucket.class);
        } else {
            // make a new bucket
            version = 0;
            bucket = new RateLimiterBucket();
        }
        bucket.resetIfNecessary(period);

        final RateLimitResponse rlr = new RateLimitResponse();
        if (bucket.getCount() > limit) {
            rlr.setAccepted(false);
        } else {
            rlr.setAccepted(bucket.getCount() < limit);
            bucket.setCount(bucket.getCount() + increment);
            bucket.setLast(System.currentTimeMillis());
        }
        int reset = (int) (bucket.getResetMillis(period) / 1000L);
        rlr.setReset(reset);
        rlr.setRemaining(limit - bucket.getCount());
        updateBucketAndReturn(id, bucket, rlr, version, bucketId, period, limit, increment, handler);
    } catch (Throwable e) {
        handler.handle(AsyncResultImpl.create(e, RateLimitResponse.class));
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:41,代码来源:ESRateLimiterComponent.java

示例13: getApi

import io.searchbox.core.Get; //导入依赖的package包/类
/**
 * Gets the api synchronously.
 * @param id
 * @throws IOException
 */
protected Api getApi(String id) throws IOException {
    Get get = new Get.Builder(getIndexName(), id).type("api").build(); //$NON-NLS-1$
    JestResult result = getClient().execute(get);
    if (result.isSucceeded()) {
        Api api = result.getSourceAsObject(Api.class);
        return api;
    } else {
        return null;
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:ESRegistry.java

示例14: getClient

import io.searchbox.core.Get; //导入依赖的package包/类
/**
 * Gets the client synchronously.
 * @param id
 * @throws IOException
 */
protected Client getClient(String id) throws IOException {
    Get get = new Get.Builder(getIndexName(), id).type("client").build(); //$NON-NLS-1$
    JestResult result = getClient().execute(get);
    if (result.isSucceeded()) {
        Client client = result.getSourceAsObject(Client.class);
        return client;
    } else {
        return null;
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:16,代码来源:ESRegistry.java

示例15: getByUid

import io.searchbox.core.Get; //导入依赖的package包/类
@Override
public AddOnInfoAndVersions getByUid(String uid) throws IOException {
	return client.execute(new Get.Builder(AddOnInfoAndVersions.ES_INDEX, uid).build())
			.getSourceAsObject(AddOnInfoAndVersions.class);
}
 
开发者ID:openmrs,项目名称:openmrs-contrib-addonindex,代码行数:6,代码来源:ElasticSearchIndex.java


注:本文中的io.searchbox.core.Get类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。