diff --git a/README.md b/README.md index dd02125..ffb7ae1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ After downloading the sources, run the task `mvn package`. Use the elasticsearch plugin manager to install the plugin : - $ /path-to/elasticsearch/bin/plugin -url file:./target/release/elasticsearch-river-subversion-0.3.1.zip -install river-subversion + $ /path-to/elasticsearch/bin/plugin -url file:./target/release/elasticsearch-river-subversion-0.3.3.zip -install river-subversion ### Creating a Subversion river ### Just create a new river of type "svn" and give it at least a repository and a path to index ("/" for the entire repos) : diff --git a/pom.xml b/pom.xml index b4b128a..32ba002 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.elasticsearch.plugin elasticsearch-river-subversion - 0.3.2 + 0.3.3 jar elasticsearch-river-subversion diff --git a/src/main/java/org/elasticsearch/river/subversion/SubversionCrawler.java b/src/main/java/org/elasticsearch/river/subversion/SubversionCrawler.java index 1a63d6d..0793cd9 100644 --- a/src/main/java/org/elasticsearch/river/subversion/SubversionCrawler.java +++ b/src/main/java/org/elasticsearch/river/subversion/SubversionCrawler.java @@ -161,7 +161,8 @@ public static List getRevisions(URL reposAsURL, new SubversionDocument( svnLogEntryPath, repository, - logEntry.getRevision() + logEntry.getRevision(), + subversionRevision ) ); } diff --git a/src/main/java/org/elasticsearch/river/subversion/SubversionRiver.java b/src/main/java/org/elasticsearch/river/subversion/SubversionRiver.java index 711aeec..bb84500 100644 --- a/src/main/java/org/elasticsearch/river/subversion/SubversionRiver.java +++ b/src/main/java/org/elasticsearch/river/subversion/SubversionRiver.java @@ -343,6 +343,9 @@ private void executeBulks(List bulks) { if (response.hasFailures()) { logger.error("failed to execute" + response.buildFailureMessage()); } + logger.info("Completed bulk {} actions in {}ms", + response.getItems().length, + response.getTookInMillis()); } catch (Exception e) { logger.error("failed to execute bulk", e); } diff --git a/src/main/java/org/elasticsearch/river/subversion/bean/SubversionDocument.java b/src/main/java/org/elasticsearch/river/subversion/bean/SubversionDocument.java index 02db5cf..85cd8e1 100644 --- a/src/main/java/org/elasticsearch/river/subversion/bean/SubversionDocument.java +++ b/src/main/java/org/elasticsearch/river/subversion/bean/SubversionDocument.java @@ -26,6 +26,7 @@ import org.tmatesoft.svn.core.io.SVNRepository; import java.nio.file.Paths; +import java.util.Date; /** * JavaBean for handling JSON generation from SVNEntries @@ -35,22 +36,37 @@ @SuppressWarnings("unused") public class SubversionDocument { - @Expose final String path; // File path - @Expose final String name; // File name - @Expose final long size; // File size - @Expose final char change; // Type of change - @Expose final String content; // File content - @Expose final long from; // Parent revision - @Expose final String origin; // Parent path + @Expose final String path; // File path + @Expose final String name; // File name + @Expose final String fullname; // Full File name + @Expose final long size; // File size + @Expose final char change; // Type of change + @Expose final String content; // File content + @Expose final long from; // Parent revision + @Expose final String origin; // Parent path + @Expose final String author; // Comitter + @Expose final String repository; // File repository + @Expose final long revision; // revision number + @Expose final Date date; // Commit date + @Expose final String message; // Commit message public static final String TYPE_NAME = "svndocument"; - public SubversionDocument(SVNLogEntryPath entryPath, SVNRepository repository, long revision) + public SubversionDocument(SVNLogEntryPath entryPath, + SVNRepository repository, + long revisionNumber, + SubversionRevision revision) throws SVNException { this.path = Paths.get(entryPath.getPath()).getParent().toString(); + this.fullname = entryPath.getPath(); this.change = entryPath.getType(); this.origin = entryPath.getCopyPath(); this.from = entryPath.getCopyRevision(); + this.author = revision.author; + this.repository = revision.repository; + this.revision = revision.revision; + this.date = revision.date; + this.message = revision.message; // First check the type of the changement ofthe entry, // for it implies which type of info // we'll be able to extract. @@ -60,7 +76,7 @@ public SubversionDocument(SVNLogEntryPath entryPath, SVNRepository repository, l || change == 'M') { SVNDirEntry dirEntry = repository.info( entryPath.getPath(), - revision + revisionNumber ); // ...and init a SubversionDocument to add to the revision this.content = SubversionCrawler.getContent(dirEntry, repository); diff --git a/src/main/java/org/elasticsearch/river/subversion/mapping/SubversionDocumentMapping.java b/src/main/java/org/elasticsearch/river/subversion/mapping/SubversionDocumentMapping.java index 6564119..4ff1ad1 100644 --- a/src/main/java/org/elasticsearch/river/subversion/mapping/SubversionDocumentMapping.java +++ b/src/main/java/org/elasticsearch/river/subversion/mapping/SubversionDocumentMapping.java @@ -66,6 +66,19 @@ public static XContentBuilder getInstance() throws IOException { .endObject() .endObject() .endObject() + .startObject("fullname") + .field("type", "multi_field") + .startObject("fields") + .startObject("fullname") + .field("type", "string") + .field("index", "analyzed") + .endObject() + .startObject("untouched") + .field("type", "string") + .field("index", "not_analyzed") + .endObject() + .endObject() + .endObject() .startObject("size") .field("type", "integer") .field("index", "not_analyzed") @@ -95,6 +108,36 @@ public static XContentBuilder getInstance() throws IOException { .endObject() .endObject() .endObject() + .startObject("author") + .field("type", "multi_field") + .startObject("fields") + .startObject("author") + .field("type", "string") + .field("index", "analyzed") + .endObject() + .startObject("untouched") + .field("type", "string") + .field("index", "not_analyzed") + .endObject() + .endObject() + .endObject() + .startObject("repository") + .field("type", "string") + .field("index", "not_analyzed") + .endObject() + .startObject("revision") + .field("type", "long") + .field("index", "not_analyzed") + .endObject() + .startObject("date") + .field("type", "date") + .field("format", "date_time") + .field("index", "analyzed") + .endObject() + .startObject("message") + .field("type", "string") + .field("index", "analyzed") + .endObject() .endObject() .endObject() .endObject(); diff --git a/src/test/resources/document.json b/src/test/resources/document.json index e0ee87c..1af0b78 100644 --- a/src/test/resources/document.json +++ b/src/test/resources/document.json @@ -1,8 +1,14 @@ { - "path": "/module2/trunk/playlist.txt", + "path": "/module2/trunk", "name": "playlist.txt", "size": 88, "change": "M", "content": "Hey, maybe I\u0027ll try this Metal Gear Solid series the internet won\u0027t stop arguing about.\n", - "from": -1 + "from": -1, + "author": "Pascal.Lombard", + "repository": "/home/Pascal.Lombard/Workspace/workspace-git/SubversionRiver/target/test-classes/TEST_REPOS", + "revision": 6, + "date": "2013-02-09T11:00:30.561+0100", + "message": "what the hell ?", + "fullname": "/module2/trunk/playlist.txt" } \ No newline at end of file