本文整理汇总了Java中org.elasticsearch.common.collect.Sets类的典型用法代码示例。如果您正苦于以下问题:Java Sets类的具体用法?Java Sets怎么用?Java Sets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sets类属于org.elasticsearch.common.collect包,在下文中一共展示了Sets类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPinYin_Index
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
/**
* 解析词条拼音
*
* @param word
* @return
*/
public static Set<String> getPinYin_Index(String word) {
Set<String> results = Sets.newHashSet();
List<String> words = AnalyzeHelper.analyze(word);
if (!words.contains(word)) {
words.add(word);
}
String pinYin;
for (String w : words) {
pinYin = getPinYin(w);
if (StringUtils.isNotEmpty(pinYin)) {
results.add(pinYin);
}
}
return results;
}
示例2: getPinYinPrefix_Index
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
/**
* 解析词条拼音首字母
*
* @param word
* @return
*/
public static Set<String> getPinYinPrefix_Index(String word) {
Set<String> results = Sets.newHashSet();
List<String> words = AnalyzeHelper.analyze(word);
if (!words.contains(word)) {
words.add(word);
}
String prefixPinYin;
for (String w : words) {
prefixPinYin = getPinYinPrefix(w);
if (StringUtils.isNotEmpty(prefixPinYin)) {
results.add(prefixPinYin);
}
}
return results;
}
示例3: getIndexes
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
/**
* Retrieves the current indexes and types from elasticsearch
* @return a set containing the indexes available in the elasticsearch cluster and their types
*/
protected Set<Index> getIndexes() {
ClusterStateResponse response = unwrapShellNativeClient().client().admin().cluster().prepareState().setFilterBlocks(true)
.setFilterRoutingTable(true).setFilterNodes(true).execute().actionGet();
Set<Index> newIndexes = new HashSet<Index>();
for (IndexMetaData indexMetaData : response.getState().metaData().indices().values()) {
logger.trace("Processing index {}", indexMetaData.index());
Set<String> typeNames = Sets.filter(indexMetaData.mappings().keySet(), new Predicate<String>() {
@Override
public boolean apply(String s) {
return !MapperService.DEFAULT_MAPPING.equals(s);
}
});
String[] types = typeNames.toArray(new String[typeNames.size()]);
newIndexes.add(new Index(indexMetaData.index(), false, types));
for (String alias : indexMetaData.aliases().keySet()) {
newIndexes.add(new Index(alias, true, types));
}
}
return newIndexes;
}
示例4: getStdNums
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
protected Collection<StandardNumber> getStdNums() {
if (stdnums.get() == null) {
String[] s = settings.getAsArray("number_types", null);
Set<String> types = s != null ? Sets.newTreeSet(Arrays.asList(s)) : null;
Set<StandardNumber> set = Sets.newLinkedHashSet();
set.addAll(types == null ? create() : create(types));
stdnums.set(set);
}
return stdnums.get();
}
示例5: testCustomFromJson
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCustomFromJson() throws Exception {
Index index = new Index("test");
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/icu/icu_collation.json").build();
AnalysisService analysisService = createAnalysisService(index, settings);
Analyzer analyzer = analysisService.analyzer("icu_german_collate").analyzer();
String[] words = new String[]{
"Göbel",
"Goethe",
"Goldmann",
"Göthe",
"Götz"
};
SetMultimap<BytesRef,String> bytesRefMap =
Multimaps.newSetMultimap(new TreeMap<BytesRef, Collection<String>>(), new Supplier<Set<String>>() {
@Override
public Set<String> get() {
return Sets.newTreeSet();
}
});
for (String s : words) {
TokenStream ts = analyzer.tokenStream(null, s);
bytesRefMap.put(bytesFromTokenStream(ts), s);
}
Iterator<Collection<String>> it = bytesRefMap.asMap().values().iterator();
assertEquals("[Göbel]",it.next().toString());
assertEquals("[Goethe, Göthe]",it.next().toString());
assertEquals("[Götz]",it.next().toString());
assertEquals("[Goldmann]",it.next().toString());
}
示例6: testFromJson
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
@Test
public void testFromJson() throws Exception {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/sortform/sortform.json").build();
AnalysisService analysisService = createAnalysisService(settings);
Analyzer analyzer = analysisService.analyzer("german_phonebook_with_sortform").analyzer();
String[] words = new String[]{
"¬Frau¬ Göbel",
"Goethe",
"¬Dr.¬ Goldmann",
"Göthe",
"¬Herr¬ Götz",
"Groß",
"Gross"
};
SetMultimap<BytesRef,String> bytesRefMap =
Multimaps.newSetMultimap(new TreeMap<BytesRef, Collection<String>>(), new Supplier<Set<String>>() {
@Override
public Set<String> get() {
return Sets.newTreeSet();
}
});
for (String s : words) {
TokenStream ts = analyzer.tokenStream(null, s);
bytesRefMap.put(bytesFromTokenStream(ts), s);
}
// strength "quaternary" orders without punctuation and ensures unique entries.
Iterator<Collection<String>> it = bytesRefMap.asMap().values().iterator();
assertEquals("[¬Frau¬ Göbel]",it.next().toString());
assertEquals("[Goethe]",it.next().toString());
assertEquals("[Göthe]",it.next().toString());
assertEquals("[¬Herr¬ Götz]",it.next().toString());
assertEquals("[¬Dr.¬ Goldmann]",it.next().toString());
assertEquals("[Gross]",it.next().toString());
assertEquals("[Groß]",it.next().toString());
}
示例7: facets
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
@Override
public QueryBuilderHelper facets() {
Set<String> aggIds = Sets.newHashSet();
for (Class<?> clazz : classes) {
if (filters == null) {
addAggregations(new HashMap(), clazz.getName(), searchRequestBuilder, aggIds);
} else {
addAggregations(filters, clazz.getName(), searchRequestBuilder, aggIds);
}
}
return this;
}
示例8: testPropertyInfoWithTxn
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
@Test
public void testPropertyInfoWithTxn() throws StoreException {
CompletionTime ct1 = new CompletionTime();
ct1.setTransaction("trace1");
ct1.setTimestamp(1000);
ct1.getProperties().add(new Property(Constants.PROP_PRINCIPAL, "p1"));
ct1.getProperties().add(new Property("prop1", "value1"));
ct1.getProperties().add(new Property("prop2", "value2"));
CompletionTime ct2 = new CompletionTime();
ct2.setTransaction("trace1");
ct2.setTimestamp(2000);
ct2.getProperties().add(new Property(Constants.PROP_PRINCIPAL, "p2"));
ct2.getProperties().add(new Property("prop3", "value3"));
ct2.getProperties().add(new Property("prop2", "value2"));
analytics.storeTraceCompletions(null, Arrays.asList(ct1, ct2));
Criteria criteria = new Criteria()
.setTransaction("trace1")
.setStartTime(1)
.setEndTime(0);
Wait.until(() -> analytics.getPropertyInfo(null, criteria).size() == 4);
java.util.List<PropertyInfo> pis = analytics.getPropertyInfo(null, criteria);
assertNotNull(pis);
assertEquals(4, pis.size());
assertEquals(Sets.newHashSet("prop1", "prop2", "prop3", Constants.PROP_PRINCIPAL),
pis.stream().map(pi -> pi.getName()).collect(Collectors.toSet()));
Criteria criteria2 =new Criteria()
.setTransaction("trace1")
.addProperty(Constants.PROP_PRINCIPAL, "p1", Operator.HAS)
.setStartTime(1)
.setEndTime(0);
Wait.until(() -> analytics.getPropertyInfo(null, criteria2).size() == 3);
pis = analytics.getPropertyInfo(null, criteria2);
assertNotNull(pis);
assertEquals(3, pis.size());
assertEquals(Sets.newHashSet("prop1", "prop2", Constants.PROP_PRINCIPAL),
pis.stream().map(pi -> pi.getName()).collect(Collectors.toSet()));
}
示例9: setTriggerFunctions
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
public void setTriggerFunctions(Collection<String> triggerFunctions) {
this.triggerFunctions = (triggerFunctions instanceof Set)
? (Set)triggerFunctions : Sets.newHashSet(triggerFunctions);
}
示例10: test_dynamodb_river
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
@Test
public void test_dynamodb_river() throws IOException, InterruptedException {
String tableName = randomAsciiOfLengthBetween(10, 50).toLowerCase();
AmazonDynamoDBClient dynamoDBClient = getDynamoClient(tableName);
// add test items to dynamodb
Set<String> idSet = Sets.newHashSet();
idSet.addAll(addTestItems(dynamoDBClient, tableName, randomIntBetween(1, 50)));
Map<String, String> dynamoDbSetting = Maps.newHashMap();
dynamoDbSetting.put("access_key", "test");
dynamoDbSetting.put("secret_key", "test");
dynamoDbSetting.put("region", "http://localhost:8000"); // test use DynamoDB Local
dynamoDbSetting.put("table_name", tableName);
dynamoDbSetting.put("updated_timestamp_field", "updated");
dynamoDbSetting.put("deleted_timestamp_field", "deleted");
dynamoDbSetting.put("interval", "1s");
dynamoDbSetting.put("bulk_size", "2"); // less bulk size so items can be indexed when doing test
dynamoDbSetting.put("flush_interval", "1s"); // less bulk interval so items can be indexed when doing test
XContentBuilder riverBuilder = jsonBuilder().startObject();
riverBuilder.field("type", "dynamodb");
riverBuilder.field("dynamodb", dynamoDbSetting);
riverBuilder.endObject();
client().prepareIndex("_river", "dynamodb", "_meta").setSource(riverBuilder).get();
Thread.sleep(10000);
client().admin().indices().prepareRefresh(tableName).get();
long count1 = client().prepareCount(tableName).get().getCount();
assertThat(count1, equalTo((long) idSet.size()));
// load more test data to dynamodb
idSet.addAll(addTestItems(dynamoDBClient, tableName, randomIntBetween(1, 50)));
Thread.sleep(10000);
client().admin().indices().prepareRefresh(tableName).get();
long count2 = client().prepareCount(tableName).get().getCount();
assertThat(count2, equalTo((long) idSet.size()));
// test delete
int toDelete = randomIntBetween(1, idSet.size() - 1);
for (int i = 0; i < toDelete; i ++) {
String id = idSet.iterator().next();
deleteFromDynamoDB(dynamoDBClient, tableName, id);
idSet.remove(id);
}
Thread.sleep(10000);
client().admin().indices().prepareRefresh(tableName).get();
long count3 = client().prepareCount(tableName).get().getCount();
assertThat(count3, equalTo((long) idSet.size()));
}
示例11: addTestItems
import org.elasticsearch.common.collect.Sets; //导入依赖的package包/类
private Set<String> addTestItems(AmazonDynamoDBClient dynamoDBClient, String tableName, int size) {
Set<String> idSet = Sets.newHashSet();
for (int p = 0; p < size; p ++) {
Map<String, AttributeValue> item = Maps.newHashMap();
int fields = randomIntBetween(10, 20);
for (int i = 0; i < fields; i ++) {
int t = randomIntBetween(1, 4);
switch (t){
case 1:
item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withS(randomAsciiOfLengthBetween(1, 20)));
break;
case 2:
item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withN(String.valueOf(randomInt())));
break;
case 3:
Set<String> s = Sets.newHashSet();
int ss = randomIntBetween(5, 20);
for (int a = 0; a < ss; a ++) {
s.add(randomAsciiOfLengthBetween(1, 20));
}
item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withSS(s));
break;
case 4:
Set<String> n = Sets.newHashSet();
int ns = randomIntBetween(5, 20);
for (int a = 0; a < ns; a ++) {
n.add(String.valueOf(randomIntBetween(1, 1000)));
}
item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withNS(n));
break;
}
}
String id = randomAsciiOfLengthBetween(1, 50);
idSet.add(id);
item.put("id", new AttributeValue().withS(id));
item.put("updated", new AttributeValue().withN(String.valueOf(new Date().getTime())));
PutItemRequest putItemRequest = new PutItemRequest()
.withTableName(tableName)
.withItem(item);
dynamoDBClient.putItem(putItemRequest);
}
return idSet;
}