本文整理汇总了Java中org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue方法的典型用法代码示例。如果您正苦于以下问题:Java XContentMapValues.extractValue方法的具体用法?Java XContentMapValues.extractValue怎么用?Java XContentMapValues.extractValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.support.XContentMapValues
的用法示例。
在下文中一共展示了XContentMapValues.extractValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCompletionMultiField
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public void testCompletionMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
.addMapping("my-type", createMappingSource("completion"))
);
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
assertThat(mappingMetaData, not(nullValue()));
Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
assertThat(aField.size(), equalTo(6));
assertThat(aField.get("type").toString(), equalTo("completion"));
assertThat(aField.get("fields"), notNullValue());
Map bField = ((Map) XContentMapValues.extractValue("properties.a.fields.b", mappingSource));
assertThat(bField.size(), equalTo(1));
assertThat(bField.get("type").toString(), equalTo("keyword"));
client().prepareIndex("my-index", "my-type", "1").setSource("a", "complete me").setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "complete me")).get();
assertThat(countResponse.getHits().getTotalHits(), equalTo(1L));
}
示例2: testIpMultiField
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public void testIpMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
.addMapping("my-type", createMappingSource("ip"))
);
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
assertThat(mappingMetaData, not(nullValue()));
Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
assertThat(aField.size(), equalTo(2));
assertThat(aField.get("type").toString(), equalTo("ip"));
assertThat(aField.get("fields"), notNullValue());
Map bField = ((Map) XContentMapValues.extractValue("properties.a.fields.b", mappingSource));
assertThat(bField.size(), equalTo(1));
assertThat(bField.get("type").toString(), equalTo("keyword"));
client().prepareIndex("my-index", "my-type", "1").setSource("a", "127.0.0.1").setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "127.0.0.1")).get();
assertThat(countResponse.getHits().getTotalHits(), equalTo(1L));
}
示例3: isStarted
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private boolean isStarted(){
// Refresh index before querying it.
client.admin().indices().prepareRefresh("_river").execute().actionGet();
GetResponse isStartedGetResponse = client.prepareGet("_river", riverName().name(), "_s3status").execute().actionGet();
try{
if (!isStartedGetResponse.isExists()){
XContentBuilder xb = jsonBuilder().startObject()
.startObject("amazon-s3")
.field("feedname", feedDefinition.getFeedname())
.field("status", "STARTED").endObject()
.endObject();
client.prepareIndex("_river", riverName.name(), "_s3status").setSource(xb).execute();
return true;
} else {
String status = (String)XContentMapValues.extractValue("amazon-s3.status", isStartedGetResponse.getSourceAsMap());
if ("STOPPED".equals(status)){
return false;
}
}
} catch (Exception e){
logger.warn("failed to get status for " + riverName().name() + ", throttling....", e);
}
return true;
}
示例4: buildArrayFromSettings
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
/**
* Extract array from settings (array or ; delimited String)
* @param settings Settings
* @param path Path to settings definition
* @return Array of settings
*/
@SuppressWarnings("unchecked")
public static String[] buildArrayFromSettings(Map<String, Object> settings, String path){
String[] includes;
// We manage comma separated format and arrays
if (XContentMapValues.isArray(XContentMapValues.extractValue(path, settings))) {
List<String> includesarray = (List<String>) XContentMapValues.extractValue(path, settings);
int i = 0;
includes = new String[includesarray.size()];
for (String include : includesarray) {
includes[i++] = trimAllWhitespace(include);
}
} else {
String includedef = (String) XContentMapValues.extractValue(path, settings);
includes = Strings.commaDelimitedListToStringArray(trimAllWhitespace(includedef));
}
String[] uniquelist = removeDuplicateStrings(includes);
return uniquelist;
}
示例5: buildArrayFromSettings
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
/**
* Extract array from settings (array or ; delimited String)
* @param settings Settings
* @param path Path to settings definition
* @return Array of settings
*/
@SuppressWarnings("unchecked")
public static String[] buildArrayFromSettings(Map<String, Object> settings, String path){
String[] includes;
// We manage comma separated format and arrays
if (XContentMapValues.isArray(XContentMapValues.extractValue(path, settings))) {
List<String> includesarray = (List<String>) XContentMapValues.extractValue(path, settings);
int i = 0;
includes = new String[includesarray.size()];
for (String include : includesarray) {
includes[i++] = Strings.trimAllWhitespace(include);
}
} else {
String includedef = (String) XContentMapValues.extractValue(path, settings);
includes = Strings.commaDelimitedListToStringArray(Strings.trimAllWhitespace(includedef));
}
String[] uniquelist = Strings.removeDuplicateStrings(includes);
return uniquelist;
}
示例6: isStarted
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private boolean isStarted(){
// Refresh index before querying it.
client.admin().indices().prepareRefresh("_river").execute().actionGet();
GetResponse isStartedGetResponse = client.prepareGet("_river", riverName().name(), "_drivestatus").execute().actionGet();
try{
if (!isStartedGetResponse.isExists()){
XContentBuilder xb = jsonBuilder().startObject()
.startObject("google-drive")
.field("feedname", feedDefinition.getFeedname())
.field("status", "STARTED").endObject()
.endObject();
client.prepareIndex("_river", riverName.name(), "_drivestatus").setSource(xb).execute();
return true;
} else {
String status = (String)XContentMapValues.extractValue("google-drive.status", isStartedGetResponse.getSourceAsMap());
if ("STOPPED".equals(status)){
return false;
}
}
} catch (Exception e){
logger.warn("failed to get status for " + riverName().name() + ", throttling....", e);
}
return true;
}
示例7: extractDocumentUpdated
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
public Date extractDocumentUpdated(Map<String, Object> document) {
Object val = XContentMapValues.extractValue(remoteDataFieldForUpdated, document);
if (val == null)
return null;
if (!Utils.isSimpleValue(val))
throw new SettingsException("Remote data field '" + remoteDataFieldForUpdated
+ "' must provide simple value, but value is " + val);
if (val instanceof Date)
return (Date) val;
try {
return DateTimeUtils.parseDate( val.toString(), remoteDataFieldForUpdatedFormat );
} catch (IllegalArgumentException e1) {
throw new SettingsException("Remote data field '" + remoteDataFieldForUpdated
+ "' is not reecognized: " + val);
}
}
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:20,代码来源:DocumentWithCommentsIndexStructureBuilder.java
示例8: extractDocumentDeleted
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
public boolean extractDocumentDeleted(Map<String, Object> document) {
if (document == null || remoteDataFieldForDeleted == null)
return false;
Object val = XContentMapValues.extractValue(remoteDataFieldForDeleted, document);
if (val == null)
return false;
if (!Utils.isSimpleValue(val))
throw new SettingsException("Remote data field '" + remoteDataFieldForDeleted
+ "' must provide simple value, but value is " + val);
String v = null;
if (val instanceof String) {
v = (String) val;
} else {
v = val.toString();
}
return v.equals(remoteDataValueForDeleted);
}
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:23,代码来源:DocumentWithCommentsIndexStructureBuilder.java
示例9: testGeoPointMultiField
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public void testGeoPointMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
.addMapping("my-type", createMappingSource("geo_point"))
);
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
assertThat(mappingMetaData, not(nullValue()));
Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
logger.info("Keys: {}", aField.keySet());
assertThat(aField.size(), equalTo(2));
assertThat(aField.get("type").toString(), equalTo("geo_point"));
assertThat(aField.get("fields"), notNullValue());
Map bField = ((Map) XContentMapValues.extractValue("properties.a.fields.b", mappingSource));
assertThat(bField.size(), equalTo(1));
assertThat(bField.get("type").toString(), equalTo("keyword"));
GeoPoint point = new GeoPoint(51, 19);
client().prepareIndex("my-index", "my-type", "1").setSource("a", point.toString()).setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0)
.setQuery(constantScoreQuery(geoDistanceQuery("a").point(51, 19).distance(50, DistanceUnit.KILOMETERS)))
.get();
assertThat(countResponse.getHits().getTotalHits(), equalTo(1L));
countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", point.geohash())).get();
assertThat(countResponse.getHits().getTotalHits(), equalTo(1L));
}
示例10: testTokenCountMultiField
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public void testTokenCountMultiField() throws Exception {
assertAcked(
client().admin().indices().prepareCreate("my-index")
.addMapping("my-type", XContentFactory.jsonBuilder().startObject().startObject("my-type")
.startObject("properties")
.startObject("a")
.field("type", "token_count")
.field("analyzer", "simple")
.startObject("fields")
.startObject("b")
.field("type", "keyword")
.endObject()
.endObject()
.endObject()
.endObject()
.endObject().endObject())
);
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
assertThat(mappingMetaData, not(nullValue()));
Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
assertThat(aField.size(), equalTo(3));
assertThat(aField.get("type").toString(), equalTo("token_count"));
assertThat(aField.get("fields"), notNullValue());
Map bField = ((Map) XContentMapValues.extractValue("properties.a.fields.b", mappingSource));
assertThat(bField.size(), equalTo(1));
assertThat(bField.get("type").toString(), equalTo("keyword"));
client().prepareIndex("my-index", "my-type", "1").setSource("a", "my tokens").setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "my tokens")).get();
assertThat(countResponse.getHits().getTotalHits(), equalTo(1L));
}
示例11: referenceValue
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Nullable
@Override
public Object referenceValue(Reference reference) {
if (updatedColumnValues == null) {
return super.referenceValue(reference);
}
Object value = updatedColumnValues.get(reference.ident().columnIdent().fqn());
if (value == null && !reference.ident().isColumn()) {
value = XContentMapValues.extractValue(reference.ident().columnIdent().fqn(), updatedColumnValues);
}
return reference.valueType().value(value);
}
示例12: extractIdValueFromDocumentField
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private String extractIdValueFromDocumentField(Map<String, Object> document, String idFieldName,
String idFieldConfigPropertyName) {
Object id = XContentMapValues.extractValue(idFieldName, document);
if (id == null)
return null;
if (!Utils.isSimpleValue(id))
throw new SettingsException("Remote data field '" + idFieldName + "' defined in 'index/"
+ idFieldConfigPropertyName + "' config param must provide simple value, but value is " + id);
return id.toString();
}
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:12,代码来源:DocumentWithCommentsIndexStructureBuilder.java
示例13: extractComments
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
/**
* Get all comments for document from remote system JSON data.
*
* @param document Map of Maps document data structure loaded from remote system.
* @return list of comments if available in data
*/
@SuppressWarnings("unchecked")
protected List<Map<String, Object>> extractComments(Map<String, Object> document) {
List<Map<String, Object>> comments = (List<Map<String, Object>>) XContentMapValues.extractValue(
remoteDataFieldForComments, document);
return comments;
}
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:13,代码来源:DocumentWithCommentsIndexStructureBuilder.java
示例14: addValueToTheIndex
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
/**
* Get defined value from values structure and add it into index document.
*
* @param out content builder to add indexed value field into
* @param indexField name of field for index
* @param valuePath path to get value from <code>values</code> structure. Dot notation for nested values can be used
* here (see {@link XContentMapValues#extractValue(String, Map)}).
* @param values structure to get value from. Can be <code>null</code> - nothing added in this case, but not
* exception.
* @param valueFieldFilter if value is JSON Object (java Map here) or List of JSON Objects, then fields in this
* objects are filtered to leave only fields named here and remap them - see
* {@link Utils#remapDataInMap(Map, Map)}. No filtering performed if this is <code>null</code>.
* @throws Exception
*/
@SuppressWarnings("unchecked")
protected void addValueToTheIndex(XContentBuilder out, String indexField, String valuePath,
Map<String, Object> values, Map<String, String> valueFieldFilter) throws Exception {
if (values == null) {
return;
}
Object v = null;
if (valuePath.contains(".")) {
v = XContentMapValues.extractValue(valuePath, values);
} else {
v = values.get(valuePath);
}
if (v != null && valueFieldFilter != null && !valueFieldFilter.isEmpty()) {
if (v instanceof Map) {
Utils.remapDataInMap((Map<String, Object>) v, valueFieldFilter);
} else if (v instanceof List) {
for (Object o : (List<?>) v) {
if (o instanceof Map) {
Utils.remapDataInMap((Map<String, Object>) o, valueFieldFilter);
} else {
logger.warn(
"Filter defined for field which is not filterable - remote document array field '{}' with value: {}",
valuePath, v);
}
}
} else {
logger.warn("Filter defined for field which is not filterable - remote document field '{}' with value: {}",
valuePath, v);
}
}
addValueToTheIndexField(out, indexField, v);
}
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:47,代码来源:DocumentWithCommentsIndexStructureBuilder.java
示例15: extractValue
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public Object extractValue(String path) {
return XContentMapValues.extractValue(path, loadSourceIfNeeded());
}