.put("index.merge.scheduler.max_thread_count",
Math.max(1, Math.min(3, Runtime.getRuntime().availableProcessors() / 2)))
- // Optimization TBD (second one must have ES > 1.2
- // .put("indices.memory.index_buffer_size", "512mb")
- // .put("index.translog.flush_threshold_size", "1gb")
+ // Optimization TBD (second one must have ES > 1.2) can be:
+ // indices.memory.index_buffer_size=512mb
+ // index.translog.flush_threshold_size=1gb
// Install our own listUpdate scripts
.put("script.default_lang", "native")
// Set cluster coordinates
esSettings.put("cluster.name", clusterName);
esSettings.put("node.rack_id", props.value(SONAR_NODE_NAME, "unknown"));
- // esSettings.put("cluster.routing.allocation.awareness.attributes", "rack_id");
+ esSettings.put("cluster.routing.allocation.awareness.attributes", "rack_id");
if (props.contains(SONAR_NODE_NAME)) {
esSettings.put("node.name", props.value(SONAR_NODE_NAME));
} else {
* List all tags, including system tags, defined on rules
*/
public Set<String> listTags() {
- /** using combined _TAGS field of ES until ES update that has multiTerms aggregation */
- return index.terms(RuleNormalizer.RuleField._TAGS.field());
+ /** using combined ALL_TAGS field of ES until ES update that has multiTerms aggregation */
+ return index.terms(RuleNormalizer.RuleField.ALL_TAGS.field());
}
public void update(RuleUpdate update) {
qb.should(this.termQuery(RuleNormalizer.RuleField.LANGUAGE, queryString, 3f));
qb.should(this.termQuery(RuleNormalizer.RuleField.CHARACTERISTIC, queryString, 5f));
qb.should(this.termQuery(RuleNormalizer.RuleField.SUB_CHARACTERISTIC, queryString, 5f));
- qb.should(this.termQuery(RuleNormalizer.RuleField._TAGS, queryString, 10f));
+ qb.should(this.termQuery(RuleNormalizer.RuleField.ALL_TAGS, queryString, 10f));
qb.should(this.termAnyQuery(RuleNormalizer.RuleField.CHARACTERISTIC, queryString, 1f));
qb.should(this.termAnyQuery(RuleNormalizer.RuleField.SUB_CHARACTERISTIC, queryString, 1f));
- qb.should(this.termAnyQuery(RuleNormalizer.RuleField._TAGS, queryString, 1f));
+ qb.should(this.termAnyQuery(RuleNormalizer.RuleField.ALL_TAGS, queryString, 1f));
return qb;
}
}
if (!CollectionUtils.isEmpty(query.getTags())) {
- filters.put(RuleNormalizer.RuleField._TAGS.field(),
- FilterBuilders.termsFilter(RuleNormalizer.RuleField._TAGS.field(), query.getTags()));
+ filters.put(RuleNormalizer.RuleField.ALL_TAGS.field(),
+ FilterBuilders.termsFilter(RuleNormalizer.RuleField.ALL_TAGS.field(), query.getTags()));
}
// Construct the debt filter on effective char and subChar
BoolFilterBuilder tagsFacetFilter = FilterBuilders.boolFilter().must(FilterBuilders.queryFilter(query));
for (Map.Entry<String, FilterBuilder> filter : filters.entrySet()) {
- if (!StringUtils.equals(filter.getKey(), RuleNormalizer.RuleField._TAGS.field())) {
+ if (!StringUtils.equals(filter.getKey(), RuleNormalizer.RuleField.ALL_TAGS.field())) {
tagsFacetFilter.must(filter.getValue());
}
}
.filter(tagsFacetFilter)
.subAggregation(
AggregationBuilders.terms(FACET_TAGS)
- .field(RuleNormalizer.RuleField._TAGS.field())
+ .field(RuleNormalizer.RuleField.ALL_TAGS.field())
.order(Terms.Order.count(false))
.size(10)
.minDocCount(1))));
public static final IndexField NOTE_LOGIN = add(IndexField.Type.STRING, "noteLogin");
public static final IndexField NOTE_CREATED_AT = add(IndexField.Type.DATE, "noteCreatedAt");
public static final IndexField NOTE_UPDATED_AT = add(IndexField.Type.DATE, "noteUpdatedAt");
- public static final IndexField _TAGS = addSearchable(IndexField.Type.STRING, "_tags");
+ public static final IndexField ALL_TAGS = addSearchable(IndexField.Type.STRING, "allTags");
public static final IndexField PARAMS = addEmbedded("params", RuleParamField.ALL_FIELDS);
public static final Set<IndexField> ALL_FIELDS = getAllFields();
// TODO Legacy PARENT_ID in DTO should be parent_key
Integer templateId = rule.getTemplateId();
+ String templateKeyFieldValue = null;
if (templateId != null) {
RuleDto templateRule = db.ruleDao().getById(session, templateId);
- RuleKey templateKey = templateRule.getKey();
- update.put(RuleField.TEMPLATE_KEY.field(), templateKey != null ? templateKey.toString() : null);
- } else {
- update.put(RuleField.TEMPLATE_KEY.field(), null);
+ if (templateRule != null) {
+ RuleKey templateKey = templateRule.getKey();
+ templateKeyFieldValue = templateKey != null ? templateKey.toString() : null;
+ }
}
+ update.put(RuleField.TEMPLATE_KEY.field(), templateKeyFieldValue);
// TODO Legacy ID in DTO should be Key
update.put(RuleField.CHARACTERISTIC.field(), null);
update.put(RuleField.TAGS.field(), rule.getTags());
update.put(RuleField.SYSTEM_TAGS.field(), rule.getSystemTags());
- update.put(RuleField._TAGS.field(), Sets.union(rule.getSystemTags(), rule.getTags()));
+ update.put(RuleField.ALL_TAGS.field(), Sets.union(rule.getSystemTags(), rule.getTags()));
/** Upsert elements */
Map<String, Object> upsert = getUpsertFor(RuleField.ALL_FIELDS, update);
for (ActionRequest update : updates.get()) {
if (IndexRequest.class.isAssignableFrom(update.getClass())) {
- bulkRequestBuilder.add(((IndexRequest) update));
- }
-
- else if (UpdateRequest.class.isAssignableFrom(update.getClass())) {
- bulkRequestBuilder.add(((UpdateRequest) update));
- }
-
- else if (DeleteRequest.class.isAssignableFrom(update.getClass())) {
- bulkRequestBuilder.add(((DeleteRequest) update));
- }
-
- else if (RefreshRequest.class.isAssignableFrom(update.getClass())) {
+ bulkRequestBuilder.add((IndexRequest) update);
+ } else if (UpdateRequest.class.isAssignableFrom(update.getClass())) {
+ bulkRequestBuilder.add((UpdateRequest) update);
+ } else if (DeleteRequest.class.isAssignableFrom(update.getClass())) {
+ bulkRequestBuilder.add((DeleteRequest) update);
+ } else if (RefreshRequest.class.isAssignableFrom(update.getClass())) {
hasInlineRefreshRequest = true;
- }
-
- else {
+ } else {
throw new IllegalStateException("Un-managed request type: " + update.getClass());
}
}
}
@Override
- public List<DeleteRequest> doCall(Index index) throws Exception {
+ public List<DeleteRequest> doCall(Index index) {
List<DeleteRequest> requests = new ArrayList<DeleteRequest>();
requests.add(Requests.deleteRequest(index.getIndexName())
.id(getKey())
}
@Override
- public List<UpdateRequest> doCall(Index index) throws Exception {
+ public List<UpdateRequest> doCall(Index index) {
List<UpdateRequest> updates = new ArrayList<UpdateRequest>();
updates.addAll(deleteItem(index, item, key));
for (Object otherItem : items) {
}
@Override
- public final List<K> call() throws Exception {
+ public final List<K> call() throws IllegalStateException {
if (index == null) {
throw new IllegalStateException(MISSING_INDEX_EXCEPTION);
}
return doCall(index);
}
- public abstract List<K> doCall(Index index) throws Exception;
+ public abstract List<K> doCall(Index index);
public boolean needsRefresh() {
return this.requiresRefresh;
}
@Override
- public List<ActionRequest> doCall(Index index) throws Exception {
+ public List<ActionRequest> doCall(Index index) {
List<ActionRequest> inserts = new ArrayList<ActionRequest>();
List<UpdateRequest> updates = index.getNormalizer().normalize(dto);
for (UpdateRequest update : updates) {
}
@Override
- public List<RefreshRequest> doCall(Index index) throws Exception {
+ public List<RefreshRequest> doCall(Index index) {
return ImmutableList.of(
new RefreshRequest()
.force(false)
}
@Override
- public List<UpdateRequest> doCall(Index index) throws Exception {
+ public List<UpdateRequest> doCall(Index index) {
List<UpdateRequest> updates = index.getNormalizer().normalize(dto);
for (UpdateRequest update : updates) {
update.index(index.getIndexName())
}
@Override
- public List<UpdateRequest> doCall(Index index) throws Exception {
+ public List<UpdateRequest> doCall(Index index) {
List<UpdateRequest> updates = new ArrayList<UpdateRequest>();
updates.addAll(normalizeItem(index, item, key));
for (Object otherItem : items) {