org.elasticsearch.common.collect.Sets Java Examples

The following examples show how to use org.elasticsearch.common.collect.Sets. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PinYinHelper.java    From es-service-parent with Apache License 2.0 6 votes vote down vote up
/**
 * 解析词条拼音
 * 
 * @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;
}
 
Example #2
Source File: PinYinHelper.java    From es-service-parent with Apache License 2.0 6 votes vote down vote up
/**
 * 解析词条拼音首字母
 * 
 * @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;
}
 
Example #3
Source File: ClientScopeSynchronizer.java    From elasticshell with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: AnalyticsServiceElasticsearchTest.java    From hawkular-apm with Apache License 2.0 4 votes vote down vote up
@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()));
}
 
Example #5
Source File: BaseElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void setTriggerFunctions(Collection<String> triggerFunctions) {
    this.triggerFunctions = (triggerFunctions instanceof Set)
            ? (Set)triggerFunctions : Sets.newHashSet(triggerFunctions);
}
 
Example #6
Source File: BaseElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void setTriggerFunctions(Collection<String> triggerFunctions) {
    this.triggerFunctions = (triggerFunctions instanceof Set)
            ? (Set)triggerFunctions : Sets.newHashSet(triggerFunctions);
}