本文整理汇总了Java中org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java XContentMapValues.nodeStringValue方法的具体用法?Java XContentMapValues.nodeStringValue怎么用?Java XContentMapValues.nodeStringValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.support.XContentMapValues
的用法示例。
在下文中一共展示了XContentMapValues.nodeStringValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SnapshotsSettings
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public SnapshotsSettings(RiverSettings settings) {
super();
if (settings.settings().containsKey(RIVERNAME)) {
@SuppressWarnings({ "unchecked" })
Map<String, Object> snapshotterSettings = (Map<String, Object>) settings.settings().get(RIVERNAME);
this.repository = XContentMapValues.nodeStringValue(snapshotterSettings.get("repository"), "my_backup");
this.indices = XContentMapValues.nodeStringValue(snapshotterSettings.get("indices"), "_all");
this.includeGlobalState = XContentMapValues.nodeBooleanValue(snapshotterSettings.get("include_global_state"), false);
this.frequency = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(snapshotterSettings.get("frequency"), "24h"), TimeValue.timeValueMinutes(60));
if (snapshotterSettings.get("purgeAfter") != null && snapshotterSettings.get("purgeAfter").toString().length() > 0) {
this.purgeAfter = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(snapshotterSettings.get("purgeAfter"), "240h"), TimeValue.timeValueHours(240));
} else {
this.purgeAfter = null;
}
this.setPurgeIndicesMustMatch(XContentMapValues.nodeBooleanValue(snapshotterSettings.get("purge_indices_must_match"), true));
} else {
this.repository = "my_backup";
this.indices = "_all";
this.includeGlobalState = false;
this.frequency = TimeValue.timeValueHours(24);
this.purgeAfter = null; // no purging by default
this.setPurgeIndicesMustMatch(true);
}
}
示例2: createFeeder
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private Feeder createFeeder(String riverType, String riverName, RiverSettings riverSettings) {
JDBCFeeder feeder = null;
try {
Map<String, Object> spec = (Map<String, Object>) riverSettings.settings().get("jdbc");
Map<String, String> loadedSettings = new JsonSettingsLoader().load(jsonBuilder().map(spec).string());
Settings mySettings = settingsBuilder().put(loadedSettings).build();
String strategy = XContentMapValues.nodeStringValue(spec.get("strategy"), "simple");
RiverFlow riverFlow = RiverServiceLoader.findRiverFlow(strategy);
logger.debug("found river flow class {} for strategy {}", riverFlow.getClass().getName(), strategy);
feeder = riverFlow.getFeeder();
logger.debug("spec = {} settings = {}", spec, mySettings.getAsMap());
feeder.setName(riverName)
.setType(riverType)
.setSpec(spec).setSettings(mySettings);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return feeder;
}
示例3: createRiverContext
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
protected void createRiverContext(String riverType, String riverName, Map<String, Object> mySettings) throws IOException {
super.createRiverContext(riverType, riverName, mySettings);
// defaults for column strategy
String columnCreatedAt = XContentMapValues.nodeStringValue(mySettings.get("created_at"), "created_at");
String columnUpdatedAt = XContentMapValues.nodeStringValue(mySettings.get("updated_at"), "updated_at");
String columnDeletedAt = XContentMapValues.nodeStringValue(mySettings.get("deleted_at"), null);
boolean columnEscape = XContentMapValues.nodeBooleanValue(mySettings.get("column_escape"), true);
TimeValue lastRunTimeStampOverlap = XContentMapValues.nodeTimeValue(mySettings.get("last_run_timestamp_overlap"),
TimeValue.timeValueSeconds(0));
riverContext
.columnCreatedAt(columnCreatedAt)
.columnUpdatedAt(columnUpdatedAt)
.columnDeletedAt(columnDeletedAt)
.columnEscape(columnEscape)
.setLastRunTimeStampOverlap(lastRunTimeStampOverlap);
}
示例4: testAttachments
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的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));
}
示例5: parseConfig
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private void parseConfig() {
if (settings.settings().containsKey("wildfly")) {
Map<String, Object> wildflySettings = (Map<String, Object>) settings.settings().get("wildfly");
this.username = XContentMapValues.nodeStringValue(wildflySettings.get("user"), null);
this.password = XContentMapValues.nodeStringValue(wildflySettings.get("user"), null);
this.host = XContentMapValues.nodeStringValue(wildflySettings.get("host"), null);
this.port = XContentMapValues.nodeIntegerValue(wildflySettings.get("port"), 9999);
this.scheduleSeconds = XContentMapValues.nodeIntegerValue(wildflySettings.get("schedule"), 1);
}
else
{
logger.error("invalid wildfly plugin configuration");
}
if (settings.settings().containsKey("index")) {
Map<String, Object> indexSettings = (Map<String, Object>) settings.settings().get("index");
indexName = XContentMapValues.nodeStringValue(indexSettings.get("index"), riverName.name());
typeName = XContentMapValues.nodeStringValue(indexSettings.get("type"), "status");
}
else
{
logger.error("invalid wildfly plugin configuration");
}
}
示例6: newScript
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
public ExecutableScript newScript(@Nullable Map<String, Object> params) {
String fieldName = params == null ? null : XContentMapValues.nodeStringValue(params.get("field"), null);
String hashValue = params == null ? null : XContentMapValues.nodeStringValue(params.get("hash"), null);
if (fieldName == null) {
throw new ScriptException("Missing the field parameter");
}
return new HammingDistanceScript(fieldName, hashValue);
}
开发者ID:scirag,项目名称:elastic-search-hamming-distance-plugin,代码行数:11,代码来源:HammingDistanceScriptFactory.java
示例7: newScript
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public ExecutableScript newScript(@Nullable Map<String, Object> params) {
String pattern = params == null ? "" :
XContentMapValues.nodeStringValue(params.get("pattern"), "");
String fieldName = params == null ? "" :
XContentMapValues.nodeStringValue(params.get("fieldName"), "");
String groupkeys = params == null ? "" :
XContentMapValues.nodeStringValue(params.get("groupkeys"), "");
String isHashMap = params == null ? "" :
XContentMapValues.nodeStringValue(params.get("isHashMap"), "");
if (StringUtils.isBlank(fieldName)) {
throw new ScriptException("Missing field parameter");
}
if (StringUtils.isBlank(pattern)) {
throw new ScriptException("Missing field parameter");
}
List<String> groupkeyList = new ArrayList<>();
if (StringUtils.isNotBlank(groupkeys)) {
groupkeyList = Arrays.asList(groupkeys.split(","));
}
Boolean isHashMapBoolean;
if (StringUtils.isBlank(isHashMap) || "false".equals(isHashMap.toLowerCase())) {
isHashMapBoolean = false;
} else {
isHashMapBoolean = true;
}
return new GrokNativeScript(pattern, fieldName, groupkeyList, isHashMapBoolean);
}
示例8: readConfig
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
private String readConfig(final String config, final String defaultValue) {
if (settings.settings().containsKey("bigquery")) {
Map<String, Object> bqSettings = (Map<String, Object>) settings.settings().get("bigquery");
return XContentMapValues.nodeStringValue(bqSettings.get(config), defaultValue);
}
return defaultValue;
}
示例9: GitHubRiver
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
@Inject
public GitHubRiver(RiverName riverName, RiverSettings settings, Client client) {
super(riverName, settings);
this.client = client;
if (!settings.settings().containsKey("github")) {
throw new IllegalArgumentException("Need river settings - owner and repository.");
}
// get settings
Map<String, Object> githubSettings = (Map<String, Object>) settings.settings().get("github");
owner = XContentMapValues.nodeStringValue(githubSettings.get("owner"), null);
repository = XContentMapValues.nodeStringValue(githubSettings.get("repository"), null);
index = String.format("%s&%s", owner, repository);
userRequestedInterval = XContentMapValues.nodeIntegerValue(githubSettings.get("interval"), 60);
// auth (optional)
username = null;
password = null;
if (githubSettings.containsKey("authentication")) {
Map<String, Object> auth = (Map<String, Object>) githubSettings.get("authentication");
username = XContentMapValues.nodeStringValue(auth.get("username"), null);
password = XContentMapValues.nodeStringValue(auth.get("password"), null);
}
// endpoint (optional - default to github.com)
endpoint = XContentMapValues.nodeStringValue(githubSettings.get("endpoint"), "https://api.github.com");
logger.info("Created GitHub river.");
}
示例10: newScript
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
/**
* This method is called for every search on every shard.
*
* @param params list of script parameters passed with the query
* @return new native script
*/
@Override
public ExecutableScript newScript(@Nullable Map<String, Object> params) {
if (params == null) {
throw new ScriptException("Missing script parameters");
}
// stoic specific concept. if the name of the index for the hit is "b-something"
// and no index is defined, we generate the lookup index by replacing the hit's index "b-" by "u-$tenant-"
String tenant = XContentMapValues.nodeStringValue(params.get("tenant"), null);
String index = XContentMapValues.nodeStringValue(params.get("index"), null);
String type = XContentMapValues.nodeStringValue(params.get("type"), null);
String id = XContentMapValues.nodeStringValue(params.get("id"), null);
String sourceIndex = XContentMapValues.nodeStringValue(params.get("source_index"), null);
String sourceType = XContentMapValues.nodeStringValue(params.get("source_type"), null);
String sourceId = XContentMapValues.nodeStringValue(params.get("source_id"), null);
String targetSource = XContentMapValues.nodeStringValue(params.get("target_source"), null);
String targetSourceIncludes = XContentMapValues.nodeStringValue(params.get("target_source_includes"), null);
String targetSourceExcludes = XContentMapValues.nodeStringValue(params.get("target_source_excludes"), null);
String targetSourceLwc = XContentMapValues.nodeStringValue(params.get("target_source_lwc"), null);
String missing = XContentMapValues.nodeStringValue(params.get("missing"), null);
String cacheFieldSave = XContentMapValues.nodeStringValue(params.get("cache_field_save"), null); // write a cache field on the document.
String cachedFieldRead = XContentMapValues.nodeStringValue(params.get("cached_field"), null);
return new JoinerScript(node.client(), logger, cache,
tenant, index, type, id,
sourceIndex, sourceType, sourceId,
targetSource, targetSourceIncludes, targetSourceExcludes,
targetSourceLwc, missing,
cacheFieldSave, cachedFieldRead);
}
示例11: LdapLoginSource
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public LdapLoginSource(Map<String, Object> settings, String masterUser, String masterPassword) {
fUserNames = new ArrayList<>();
fUserPasswords = new ArrayList<>();
fMasterUser = masterUser;
fMasterPassword = masterPassword;
String url = XContentMapValues.nodeStringValue(settings.get("ldap_url"), null);
String base = XContentMapValues.nodeStringValue(settings.get("ldap_base"), null);
String user = XContentMapValues.nodeStringValue(settings.get("ldap_user"), null);
String password = XContentMapValues.nodeStringValue(settings.get("ldap_password"), null);
fConnector = new SimpleLdapConnector(url, base, user, password, true);
fNameField = XContentMapValues.nodeStringValue(settings.get("ldap_name_field"), DEF_USER_NAME_FIELD);
fPasswordField = XContentMapValues.nodeStringValue(settings.get("ldap_password_field"), DEF_USER_PW_FIELD);
fLdapFilter = fNameField + "=*";
fLogger = ESLoggerFactory.getLogger(LdapLoginSource.class.getName());
fLock = new Object();
fInitialized = false;
//start refreshing thread once initialized; interval in minutes
String refreshParam = XContentMapValues.nodeStringValue(settings.get("ldap_refresh_interval"), DEF_REFRESH_INT);
fRefreshInt = Long.parseLong(refreshParam) * 60000L;
if(fRefreshInt > 0) {
//TODO: actually stop refreshing thread somehow
fActive = true;
Thread t = new Thread(this);
t.setDaemon(true);
t.start();
}
}
示例12: arrayNodeToList
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<String> arrayNodeToList(Object arrayNode) {
ArrayList<String> list = new ArrayList<>();
if(XContentMapValues.isArray(arrayNode)) {
for(Object node : (List<Object>) arrayNode) {
String value = XContentMapValues.nodeStringValue(node, null);
if(value != null) {
list.add(value);
}
}
}
return list;
}
示例13: getUserLogins
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private void getUserLogins(final Map<String, Object> imapSettings) {
String userSource = XContentMapValues.nodeStringValue(imapSettings.get("user_source"), null);
ILoginSource source = null;
if ("ldap".equals(userSource)) {
//master user credentials for Dovecot
String masterUser = XContentMapValues.nodeStringValue(imapSettings.get("master_user"), null);
String masterPassword = XContentMapValues.nodeStringValue(imapSettings.get("master_password"), null);
source = new LdapLoginSource(imapSettings, masterUser, masterPassword);
} else {
//read logins directly
String _user = XContentMapValues.nodeStringValue(imapSettings.get("user"), null);
String _password = XContentMapValues.nodeStringValue(imapSettings.get("password"), null);
if (_user != null && !_user.isEmpty()) {
users.add(_user);
passwords.add(_password);
}
List<String> _users = arrayNodeToList(imapSettings.get("users"));
List<String> _passwords = arrayNodeToList(imapSettings.get("passwords"));
//TODO: inject master user credentials?
if (_users != null && !_users.isEmpty()) {
users.addAll(_users);
passwords.addAll(_passwords);
}
}
//read from generic source
if (source != null) {
users.addAll(source.getUserNames());
passwords.addAll(source.getUserPasswords());
}
}
示例14: ComputedFieldMapper
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
protected ComputedFieldMapper(String name, ScriptService scriptService, Map<String, Object> mappings, Mapper resultMapper)
{
_logger = Loggers.getLogger("computed-fields", SettingsHelper.GetSettings(), name);
_name = name;
_scriptService = scriptService;
_mappings = mappings;
_resultMapper = resultMapper;
String lang = XContentMapValues.nodeStringValue(mappings.get("lang"), null);
String script = XContentMapValues.nodeStringValue(mappings.get("script"), null);
if (script != null) _script = scriptService.compile(lang, script);
else _script = null;
boolean externalValueSupported = false;
if (_resultMapper instanceof StringFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof ByteFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof ShortFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof IntegerFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof LongFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof FloatFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof DoubleFieldMapper) externalValueSupported = true;
//else if (_resultMapper instanceof BooleanFieldMapper) externalValueSupported = true;
//else if (_resultMapper instanceof BinaryFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof DateFieldMapper) externalValueSupported = true;
else if (_resultMapper instanceof IpFieldMapper) externalValueSupported = true;
//else if (_resultMapper instanceof ObjectMapper) externalValueSupported = true;
//else if (_resultMapper instanceof CompletionFieldMapper) externalValueSupported = true;
//else if (_resultMapper instanceof MultiFieldMapper) externalValueSupported = true;
//else if (_resultMapper instanceof GeoPointFieldMapper) externalValueSupported = true;
_externalValueSupported = externalValueSupported;
}
示例15: parse
import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Mapper.Builder<?, ?> parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException
{
Builder builder = new Builder(name, _scriptService, node);
Map<String, Object> result = (Map<String, Object>)node.get("result");
if (result != null)
{
String type = XContentMapValues.nodeStringValue(result.get("type"), "string");
builder.resultTypeParser(parserContext.typeParser(type).parse(name, result, parserContext));
}
return builder;
}