From 983ee1d6c4512516840718b9cb0443fbff54bd7a Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 19 Feb 2016 17:42:45 +0000 Subject: [PATCH] Documents older than a certain timestamp will be now automatically removed after indexing of newer posts (or updates of them) git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-data-indexer-se-plugin@124391 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../SocialDataIndexerPlugin.java | 72 ++++++++++++++----- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/socialnetworking/socialdataindexer/SocialDataIndexerPlugin.java b/src/main/java/org/gcube/socialnetworking/socialdataindexer/SocialDataIndexerPlugin.java index 56fd263..907b175 100644 --- a/src/main/java/org/gcube/socialnetworking/socialdataindexer/SocialDataIndexerPlugin.java +++ b/src/main/java/org/gcube/socialnetworking/socialdataindexer/SocialDataIndexerPlugin.java @@ -17,6 +17,7 @@ import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.transport.NoNodeAvailableException; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.settings.Settings; @@ -24,13 +25,15 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.shared.Attachment; import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.portal.databook.shared.Feed; -import org.gcube.portal.databook.shared.FeedType; import org.gcube.socialnetworking.social_data_indexing_common.ex.BulkInsertionFailedException; import org.gcube.socialnetworking.social_data_indexing_common.utils.ElasticSearchRunningCluster; import org.gcube.socialnetworking.social_data_indexing_common.utils.IndexFields; @@ -139,7 +142,7 @@ public class SocialDataIndexerPlugin extends Plugin feeds = store.getAllFeedsByVRE(vreID); - addEnhancedFeedsInBulk(feeds); + addEnhancedFeedsInBulk(feeds, init); logger.debug("Number of indexed feeds is " + feeds.size() + " for vre " + vreID); }catch(Exception e){ logger.debug("Exception while saving feeds/comments into the index for vre " + vreID, e); @@ -148,6 +151,9 @@ public class SocialDataIndexerPlugin extends Plugin feeds) throws BulkInsertionFailedException { + private void addEnhancedFeedsInBulk(List feeds, long init) throws BulkInsertionFailedException { logger.debug("Starting bulk insert enhanced feeds operation"); BulkProcessor bulkProcessor = BulkProcessor.builder( client, @@ -223,19 +230,15 @@ public class SocialDataIndexerPlugin extends Plugin