Skip to content

Commit

Permalink
- Altering mapping to be more inclusive. Having every information at …
Browse files Browse the repository at this point in the history
…document level is too useful to pass on, even if that means more indexing.
  • Loading branch information
plombard committed Aug 4, 2013
1 parent f9bd7d3 commit 9bb2f3a
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.elasticsearch.plugin</groupId>
<artifactId>elasticsearch-river-subversion</artifactId>
<version>0.3.2</version>
<version>0.3.3</version>
<packaging>jar</packaging>

<name>elasticsearch-river-subversion</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public static List<SubversionRevision> getRevisions(URL reposAsURL,
new SubversionDocument(
svnLogEntryPath,
repository,
logEntry.getRevision()
logEntry.getRevision(),
subversionRevision
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ private void executeBulks(List<BulkRequestBuilder> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 8 additions & 2 deletions src/test/resources/document.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 9bb2f3a

Please sign in to comment.