fix some bugs

This commit is contained in:
Michele Artini 2020-08-19 17:12:02 +02:00
parent 506f77ed60
commit beff40f729
5 changed files with 8 additions and 6 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
@Document(indexName = "#{elasticSearchProperties.eventsIndexName}", shards = 48, replicas = 0, refreshInterval = "600s")
@Document(indexName = "#{elasticSearchProperties.eventsIndexName}", shards = 48, replicas = 1, refreshInterval = "600s")
public class Event {
@Id

View File

@ -11,7 +11,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import eu.dnetlib.lbs.subscriptions.Subscription;
@Document(indexName = "#{elasticSearchProperties.notificationsIndexName}", shards = 48, replicas = 0, refreshInterval = "600s")
@Document(indexName = "#{elasticSearchProperties.notificationsIndexName}", shards = 48, replicas = 1, refreshInterval = "600s")
public class Notification {
@Id

View File

@ -12,6 +12,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -106,7 +107,7 @@ public class SubscriptionEventMatcher implements Runnable {
final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("topic", s.getTopic()))
.must(QueryBuilders.matchQuery("topic", s.getTopic()).operator(Operator.AND))
.must(QueryBuilders.rangeQuery("creationDate").from(s.getLastNotificationDate() != null ? s.getLastNotificationDate().getTime() : 0))
.must(QueryBuilders.nestedQuery("map", mapQuery, ScoreMode.None)))
.withSearchType(SearchType.DEFAULT)

View File

@ -13,6 +13,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
@ -125,7 +126,7 @@ public class OpenaireBrokerController extends AbstractLbsController {
final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("topic", topic))
.must(QueryBuilders.matchQuery("topic", topic).operator(Operator.AND))
.must(QueryBuilders.nestedQuery("map", QueryBuilders.matchQuery("map.targetDatasourceName", ds), ScoreMode.None)))
.withSearchType(SearchType.DEFAULT)
.withFields("payload")
@ -157,7 +158,7 @@ public class OpenaireBrokerController extends AbstractLbsController {
final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("topic", qObj.getTopic()))
.must(QueryBuilders.matchQuery("topic", qObj.getTopic()).operator(Operator.AND))
.must(QueryBuilders.nestedQuery("map", mapQuery, ScoreMode.None)))
.withSearchType(SearchType.DEFAULT)
.withFields("payload")

View File

@ -50,6 +50,6 @@ spring.data.elasticsearch.cluster-name = ${lbs.elastic.clusterName}
spring.data.elasticsearch.cluster-nodes = ${lbs.elastic.clusterNodes}
logging.level.root=DEBUG