本文整理汇总了Java中org.elasticsearch.common.xcontent.ToXContent.Params.param方法的典型用法代码示例。如果您正苦于以下问题:Java Params.param方法的具体用法?Java Params.param怎么用?Java Params.param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.ToXContent.Params
的用法示例。
在下文中一共展示了Params.param方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterSettings
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
public static Settings filterSettings(Params params, Settings settings) {
String patterns = params.param(SETTINGS_FILTER_PARAM);
final Settings filteredSettings;
if (patterns != null && patterns.isEmpty() == false) {
filteredSettings = filterSettings(Strings.commaDelimitedListToSet(patterns), settings);
} else {
filteredSettings = settings;
}
return filteredSettings;
}
示例2: filterSettings
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
public static Settings filterSettings(Params params, Settings settings) {
String patterns = params.param(SETTINGS_FILTER_PARAM);
Settings filteredSettings = settings;
if (patterns != null && patterns.isEmpty() == false) {
filteredSettings = SettingsFilter.filterSettings(patterns, filteredSettings);
}
return filteredSettings;
}
示例3: execute
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
/**
* Execute the reindexing
*
* @param params Rest request
* @param content Content of rest request in {}
* @param listener is to receive the response back
* @return
*/
public String execute(final Params params, final BytesReference content, final ActionListener<Void> listener) {
final String url = params.param("url");
// set scroll to 1m if there is no
final String scroll = params.param("scroll", "1m");
final String fromIndex = params.param("index");
final String fromType = params.param("type");
final String toIndex = params.param("toindex");
final String toType = params.param("totype");
final String[] fields = params.paramAsBoolean("parent", true) ? new String[]{"_source", "_parent"} : new String[]{"_source"};
final boolean deletion = params.paramAsBoolean("deletion", false);
final ReindexingListener reindexingListener = new ReindexingListener(url, fromIndex, fromType, toIndex, toType, scroll, deletion, listener);
// Create search request builder
final SearchRequestBuilder builder = client.prepareSearch(fromIndex)
.setScroll(scroll).addFields(fields);
if (fromType != null && fromType.trim().length() > 0) {
builder.setTypes(fromType.split(","));
}
if (content == null || content.length() == 0) {
builder.setQuery(QueryBuilders.matchAllQuery()).setSize(
Integer.parseInt(params.param("size", "1000")));
} else {
builder.setExtraSource(content);
}
builder.execute(reindexingListener); // async
reindexingListenerMap.put(reindexingListener.getName(), reindexingListener);
return reindexingListener.getName();
}
示例4: doItemIndexExists
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
private void doItemIndexExists(final Params params,
final RequestHandler.OnErrorListener listener,
final Map<String, Object> requestMap,
final Map<String, Object> paramMap, final RequestHandlerChain chain) {
final String index = params.param(
TasteConstants.REQUEST_PARAM_ITEM_INDEX, params.param("index"));
try {
indexCreationLock.lock();
final IndicesExistsResponse indicesExistsResponse = client.admin()
.indices().prepareExists(index).execute().actionGet();
if (indicesExistsResponse.isExists()) {
doItemMappingCreation(params, listener, requestMap, paramMap,
chain);
} else {
doItemIndexCreation(params, listener, requestMap, paramMap,
chain, index);
}
} catch (final Exception e) {
final List<Throwable> errorList = getErrorList(paramMap);
if (errorList.size() >= maxRetryCount) {
listener.onError(e);
} else {
sleep(e);
errorList.add(e);
fork(() -> execute(params, listener, requestMap, paramMap,
chain));
}
} finally {
indexCreationLock.unlock();
}
}
示例5: doPreferenceIndexExists
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
private void doPreferenceIndexExists(final Params params,
final RequestHandler.OnErrorListener listener,
final Map<String, Object> requestMap,
final Map<String, Object> paramMap, final RequestHandlerChain chain) {
final String index = params.param("index");
try {
indexCreationLock.lock();
final IndicesExistsResponse indicesExistsResponse = client.admin()
.indices().prepareExists(index).execute().actionGet();
if (indicesExistsResponse.isExists()) {
doPreferenceMappingCreation(params, listener, requestMap,
paramMap, chain);
} else {
doPreferenceIndexCreation(params, listener, requestMap,
paramMap, chain, index);
}
} catch (final Exception e) {
final List<Throwable> errorList = getErrorList(paramMap);
if (errorList.size() >= maxRetryCount) {
listener.onError(e);
} else {
sleep(e);
errorList.add(e);
fork(() -> execute(params, listener, requestMap, paramMap,
chain));
}
} finally {
indexCreationLock.unlock();
}
}
示例6: doUserIndexExists
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
private void doUserIndexExists(final Params params,
final RequestHandler.OnErrorListener listener,
final Map<String, Object> requestMap,
final Map<String, Object> paramMap, final RequestHandlerChain chain) {
final String index = params.param(
TasteConstants.REQUEST_PARAM_USER_INDEX, params.param("index"));
try {
indexCreationLock.lock();
final IndicesExistsResponse indicesExistsResponse = client.admin()
.indices().prepareExists(index).execute().actionGet();
if (indicesExistsResponse.isExists()) {
doUserMappingCreation(params, listener, requestMap, paramMap,
chain);
} else {
doUserIndexCreation(params, listener, requestMap, paramMap,
chain, index);
}
} catch (final Exception e) {
final List<Throwable> errorList = getErrorList(paramMap);
if (errorList.size() >= maxRetryCount) {
listener.onError(e);
} else {
sleep(e);
errorList.add(e);
fork(() -> execute(params, listener, requestMap, paramMap,
chain));
}
} finally {
indexCreationLock.unlock();
}
}
示例7: doItemMappingCreation
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
private void doItemMappingCreation(final Params params,
final RequestHandler.OnErrorListener listener,
final Map<String, Object> requestMap,
final Map<String, Object> paramMap, final RequestHandlerChain chain) {
final String index = params.param(
TasteConstants.REQUEST_PARAM_ITEM_INDEX, params.param("index"));
final String type = params.param(
TasteConstants.REQUEST_PARAM_ITEM_TYPE,
TasteConstants.ITEM_TYPE);
final String itemIdField = params.param(
TasteConstants.REQUEST_PARAM_ITEM_ID_FIELD,
TasteConstants.ITEM_ID_FIELD);
final String timestampField = params.param(
TasteConstants.REQUEST_PARAM_TIMESTAMP_FIELD,
TasteConstants.TIMESTAMP_FIELD);
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
final ClusterHealthResponse healthResponse = client
.admin()
.cluster()
.prepareHealth(index)
.setWaitForYellowStatus()
.setTimeout(
params.param("timeout",
DEFAULT_HEALTH_REQUEST_TIMEOUT)).execute()
.actionGet();
if (healthResponse.isTimedOut()) {
listener.onError(new OperationFailedException(
"Failed to create index: " + index + "/" + type));
}
final XContentBuilder builder = jsonBuilder//
.startObject()//
.startObject(type)//
.startObject("properties")//
// @timestamp
.startObject(timestampField)//
.field("type", "date")//
.field("format", "date_optional_time")//
.endObject()//
// item_id
.startObject(itemIdField)//
.field("type", "long")//
.endObject()//
// system_id
.startObject("system_id")//
.field("type", "string")//
.field("index", "not_analyzed")//
.endObject()//
.endObject()//
.endObject()//
.endObject();
final PutMappingResponse mappingResponse = client.admin().indices()
.preparePutMapping(index).setType(type).setSource(builder)
.execute().actionGet();
if (mappingResponse.isAcknowledged()) {
fork(() -> execute(params, listener, requestMap, paramMap,
chain));
} else {
listener.onError(new OperationFailedException(
"Failed to create mapping for " + index + "/" + type));
}
} catch (final Exception e) {
listener.onError(e);
}
}
示例8: doPreferenceMappingCreation
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
private void doPreferenceMappingCreation(final Params params,
final RequestHandler.OnErrorListener listener,
final Map<String, Object> requestMap,
final Map<String, Object> paramMap, final RequestHandlerChain chain) {
final String index = params.param("index");
final String type = params
.param("type", TasteConstants.PREFERENCE_TYPE);
final String userIdField = params.param(
TasteConstants.REQUEST_PARAM_USER_ID_FIELD,
TasteConstants.USER_ID_FIELD);
final String itemIdField = params.param(
TasteConstants.REQUEST_PARAM_ITEM_ID_FIELD,
TasteConstants.ITEM_ID_FIELD);
final String valueField = params.param(
TasteConstants.REQUEST_PARAM_VALUE_FIELD,
TasteConstants.VALUE_FIELD);
final String timestampField = params.param(
TasteConstants.REQUEST_PARAM_TIMESTAMP_FIELD,
TasteConstants.TIMESTAMP_FIELD);
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
final ClusterHealthResponse healthResponse = client
.admin()
.cluster()
.prepareHealth(index)
.setWaitForYellowStatus()
.setTimeout(
params.param("timeout",
DEFAULT_HEALTH_REQUEST_TIMEOUT)).execute()
.actionGet();
if (healthResponse.isTimedOut()) {
listener.onError(new OperationFailedException(
"Failed to create index: " + index + "/" + type));
}
final XContentBuilder builder = jsonBuilder//
.startObject()//
.startObject(type)//
.startObject("properties")//
// @timestamp
.startObject(timestampField)//
.field("type", "date")//
.field("format", "date_optional_time")//
.endObject()//
// user_id
.startObject(userIdField)//
.field("type", "long")//
.endObject()//
// item_id
.startObject(itemIdField)//
.field("type", "long")//
.endObject()//
// value
.startObject(valueField)//
.field("type", "double")//
.endObject()//
.endObject()//
.endObject()//
.endObject();
final PutMappingResponse mappingResponse = client.admin().indices()
.preparePutMapping(index).setType(type).setSource(builder)
.execute().actionGet();
if (mappingResponse.isAcknowledged()) {
fork(() -> execute(params, listener, requestMap, paramMap,
chain));
} else {
listener.onError(new OperationFailedException(
"Failed to create mapping for " + index + "/" + type));
}
} catch (final Exception e) {
listener.onError(e);
}
}
示例9: doUserMappingCreation
import org.elasticsearch.common.xcontent.ToXContent.Params; //导入方法依赖的package包/类
private void doUserMappingCreation(final Params params,
final RequestHandler.OnErrorListener listener,
final Map<String, Object> requestMap,
final Map<String, Object> paramMap, final RequestHandlerChain chain) {
final String index = params.param(
TasteConstants.REQUEST_PARAM_USER_INDEX, params.param("index"));
final String type = params.param(
TasteConstants.REQUEST_PARAM_USER_TYPE,
TasteConstants.USER_TYPE);
final String userIdField = params.param(
TasteConstants.REQUEST_PARAM_USER_ID_FIELD,
TasteConstants.USER_ID_FIELD);
final String timestampField = params.param(
TasteConstants.REQUEST_PARAM_TIMESTAMP_FIELD,
TasteConstants.TIMESTAMP_FIELD);
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
final ClusterHealthResponse healthResponse = client
.admin()
.cluster()
.prepareHealth(index)
.setWaitForYellowStatus()
.setTimeout(
params.param("timeout",
DEFAULT_HEALTH_REQUEST_TIMEOUT)).execute()
.actionGet();
if (healthResponse.isTimedOut()) {
listener.onError(new OperationFailedException(
"Failed to create index: " + index + "/" + type));
}
final XContentBuilder builder = jsonBuilder//
.startObject()//
.startObject(type)//
.startObject("properties")//
// @timestamp
.startObject(timestampField)//
.field("type", "date")//
.field("format", "date_optional_time")//
.endObject()//
// user_id
.startObject(userIdField)//
.field("type", "long")//
.endObject()//
// system_id
.startObject("system_id")//
.field("type", "string")//
.field("index", "not_analyzed")//
.endObject()//
.endObject()//
.endObject()//
.endObject();
final PutMappingResponse mappingResponse = client.admin().indices()
.preparePutMapping(index).setType(type).setSource(builder)
.execute().actionGet();
if (mappingResponse.isAcknowledged()) {
fork(() -> execute(params, listener, requestMap, paramMap,
chain));
} else {
listener.onError(new OperationFailedException(
"Failed to create mapping for " + index + "/" + type));
}
} catch (final Exception e) {
listener.onError(e);
}
}