This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Autowired | |
private BulkProcessor bulkProcessor; | |
try { | |
final IndexRequest request = // build your index request as usual | |
bulkProcessor.add(request); | |
} catch (final Exception e) { | |
LOGGER.warn("failed to add for bulk insert", e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class BulkProcessorFactoryBean extends AbstractFactoryBean<BulkProcessor> { | |
@Autowired | |
private Client client; | |
@Autowired | |
private Listener bulkProcessorListener; | |
@Value("${bulk.actionsSize:1000}") | |
private Integer actionSize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class BulkProcessorListenerFactoryBean extends AbstractFactoryBean<Listener> { | |
private static final Logger LOGGER = LoggerFactory.getLogger(BulkProcessorListenerFactoryBean.class); | |
private Listener listener; | |
@Override | |
public Class<?> getObjectType() { | |
return Listener.class; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QueryBuilder query = QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("username", username)) | |
.filter(QueryBuilders.rangeQuery("transactionDateTime").from(startDateTime).to(endDateTime)); | |
TermsBuilder withUsername = AggregationBuilders.terms("username").field("username"); | |
TermsBuilder withCurrency = AggregationBuilders.terms("currency").field("currency"); | |
SumBuilder withTotalAmount = AggregationBuilders.sum("totalAmount").field("amount"); | |
SearchResponse response = getClient().prepareSearch(getIndex()).setSearchType(SearchType.DFS_QUERY_THEN_FETCH) | |
.setTypes(getType()).setSize(0).setQuery(query).addAggregation(withUsername) | |
.addAggregation(withCurrency).addAggregation(withTotalAmount).execute().actionGet(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::: {calculation-engine-store-2.test.internal}{_hst3xu1RnanErb78KoMCQ}{10.78.126.39}{10.78.126.39:9300} | |
Hot threads at 2016-04-05T10:01:53.415Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true: | |
41.4% (207.1ms out of 500ms) cpu usage by thread 'elasticsearch[calculation-engine-store-2.test.internal][search][T#2]' | |
2/10 snapshots sharing following 25 elements | |
org.apache.lucene.search.MultiTermQueryConstantScoreWrapper$1.scorer(MultiTermQueryConstantScoreWrapper.java:213) | |
org.apache.lucene.search.LRUQueryCache$CachingWrapperWeight.scorer(LRUQueryCache.java:628) | |
org.elasticsearch.indices.cache.query.IndicesQueryCache$CachingWeightWrapper.scorer(IndicesQueryCache.java:263) | |
org.apache.lucene.search.BooleanWeight.scorer(BooleanWeight.java:389) | |
org.apache.lucene.search.LRUQueryCache$CachingWrapperWeight.scorer(LRUQueryCache.java:628) |