Skip to content

Commit d5e9be9

Browse files
committed
Add support for partial update of documents
1 parent e76aa3c commit d5e9be9

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.elasticsearch.plugin.river.eea_rdf</groupId>
55
<artifactId>eea-rdf-river-plugin</artifactId>
6-
<version>1.5.3</version>
6+
<version>1.5.3-SNAPSHORT</version>
77

88
<packaging>jar</packaging>
99

src/main/java/org/elasticsearch/river/eea_rdf/RDFRiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
*
2222
* @author EEA
23-
* Modified by Hemed 09-03-2015
23+
* Modified by Hemed, University of Bergen Library 09-03-2015
2424
*/
2525
public class RDFRiver extends AbstractRiverComponent implements River {
2626
private volatile Harvester harvester;

src/main/java/org/elasticsearch/river/eea_rdf/support/Harvester.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
*
3333
* @author EEA <br>
34-
* Customized to accommodate requests from the University of Bergen Library.
34+
* Customized to accommodate requests from the University of Bergen Library.<br>
3535
* Hemed, 09-03-2015
3636
*/
3737
public class Harvester implements Runnable {
@@ -1050,8 +1050,7 @@ private Map<String, ArrayList<String>> getJsonMap(Resource rs, Set<Property> pro
10501050

10511051
/**
10521052
* Index or update all the resources in a Jena Model to ES
1053-
* Note: Update works if the user has specified the flag "updateDocuments" to true in the river settings.
1054-
* By default it is set to false.
1053+
* Note: Update works if the user has specified the flag "updateDocuments" to true in the river settings. It is set to false by default.
10551054
* By doing this, you can partial update the documents without full re-indexing.
10561055
* @param model the model to index
10571056
* @param bulkRequest a BulkRequestBuilder
@@ -1081,9 +1080,9 @@ private void addModelToES(Model model, BulkRequestBuilder bulkRequest) throws IO
10811080
while(rsiter.hasNext()) {
10821081
Resource rs = rsiter.nextResource();
10831082
Map<String, ArrayList<String>> jsonMap = getJsonMap(rs, properties, model);
1084-
1083+
1084+
//If updateDocuments is set to true, then prepare to update this document
10851085
if(updateDocuments){
1086-
//If updateDocuments is set to true, then prepare to update this document
10871086
prepareUpdateDocument(bulkRequest, mapToString(jsonMap), rs.toString());
10881087
}
10891088
else{
@@ -1097,7 +1096,7 @@ private void addModelToES(Model model, BulkRequestBuilder bulkRequest) throws IO
10971096
if(bulkLength % numberOfBulkActions == 0) {
10981097

10991098
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
1100-
// After executing, flush the BulkRequestBuilder.
1099+
// After executing, clear the BulkRequestBuilder.
11011100
bulkRequest = client.prepareBulk();
11021101

11031102
if (bulkResponse.hasFailures()) {
@@ -1115,7 +1114,7 @@ private void addModelToES(Model model, BulkRequestBuilder bulkRequest) throws IO
11151114
}
11161115

11171116
}
1118-
//Show time taken to perfom the action
1117+
//Show time taken to perfom the action
11191118
String actionPerformed = updateDocuments == true? "update: " : "index: ";
11201119
logger.info("\n==========================================="
11211120
+"\n\tTotal documents proccessed: " + bulkLength
@@ -1146,8 +1145,8 @@ private void processBulkResponseFailure(BulkResponse response) {
11461145

11471146

11481147

1149-
/** Prepare update of a document in ElasticSearch. Given document ID, a document will be merged to the existing document
1150-
* with this ID, if document does not exist, no update will be performed and the DocumentMissingException will be thrown.
1148+
/** Prepare update of a document in ElasticSearch. Given a document ID, document will be merged to the existing document
1149+
* with this ID, if original document does not exist, no update will be performed and the DocumentMissingException will be thrown.<b>
11511150
*
11521151
* This is useful if someone wants to update a partial document in ElasticSearch without full re-indexing.
11531152
* Hemed, 09-03-2015

0 commit comments

Comments
 (0)