Skip to content

Commit 9bb2f3a

Browse files
committed
- Altering mapping to be more inclusive. Having every information at document level is too useful to pass on, even if that means more indexing.
1 parent f9bd7d3 commit 9bb2f3a

File tree

7 files changed

+83
-14
lines changed

7 files changed

+83
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ After downloading the sources, run the task `mvn package`.
1010

1111
Use the elasticsearch plugin manager to install the plugin :
1212

13-
$ /path-to/elasticsearch/bin/plugin -url file:./target/release/elasticsearch-river-subversion-0.3.1.zip -install river-subversion
13+
$ /path-to/elasticsearch/bin/plugin -url file:./target/release/elasticsearch-river-subversion-0.3.3.zip -install river-subversion
1414

1515
### Creating a Subversion river ###
1616
Just create a new river of type "svn" and give it at least a repository and a path to index ("/" for the entire repos) :

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.elasticsearch.plugin</groupId>
66
<artifactId>elasticsearch-river-subversion</artifactId>
7-
<version>0.3.2</version>
7+
<version>0.3.3</version>
88
<packaging>jar</packaging>
99

1010
<name>elasticsearch-river-subversion</name>

src/main/java/org/elasticsearch/river/subversion/SubversionCrawler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ public static List<SubversionRevision> getRevisions(URL reposAsURL,
161161
new SubversionDocument(
162162
svnLogEntryPath,
163163
repository,
164-
logEntry.getRevision()
164+
logEntry.getRevision(),
165+
subversionRevision
165166
)
166167
);
167168
}

src/main/java/org/elasticsearch/river/subversion/SubversionRiver.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ private void executeBulks(List<BulkRequestBuilder> bulks) {
343343
if (response.hasFailures()) {
344344
logger.error("failed to execute" + response.buildFailureMessage());
345345
}
346+
logger.info("Completed bulk {} actions in {}ms",
347+
response.getItems().length,
348+
response.getTookInMillis());
346349
} catch (Exception e) {
347350
logger.error("failed to execute bulk", e);
348351
}

src/main/java/org/elasticsearch/river/subversion/bean/SubversionDocument.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.tmatesoft.svn.core.io.SVNRepository;
2727

2828
import java.nio.file.Paths;
29+
import java.util.Date;
2930

3031
/**
3132
* JavaBean for handling JSON generation from SVNEntries
@@ -35,22 +36,37 @@
3536
@SuppressWarnings("unused")
3637
public class SubversionDocument {
3738

38-
@Expose final String path; // File path
39-
@Expose final String name; // File name
40-
@Expose final long size; // File size
41-
@Expose final char change; // Type of change
42-
@Expose final String content; // File content
43-
@Expose final long from; // Parent revision
44-
@Expose final String origin; // Parent path
39+
@Expose final String path; // File path
40+
@Expose final String name; // File name
41+
@Expose final String fullname; // Full File name
42+
@Expose final long size; // File size
43+
@Expose final char change; // Type of change
44+
@Expose final String content; // File content
45+
@Expose final long from; // Parent revision
46+
@Expose final String origin; // Parent path
47+
@Expose final String author; // Comitter
48+
@Expose final String repository; // File repository
49+
@Expose final long revision; // revision number
50+
@Expose final Date date; // Commit date
51+
@Expose final String message; // Commit message
4552

4653
public static final String TYPE_NAME = "svndocument";
4754

48-
public SubversionDocument(SVNLogEntryPath entryPath, SVNRepository repository, long revision)
55+
public SubversionDocument(SVNLogEntryPath entryPath,
56+
SVNRepository repository,
57+
long revisionNumber,
58+
SubversionRevision revision)
4959
throws SVNException {
5060
this.path = Paths.get(entryPath.getPath()).getParent().toString();
61+
this.fullname = entryPath.getPath();
5162
this.change = entryPath.getType();
5263
this.origin = entryPath.getCopyPath();
5364
this.from = entryPath.getCopyRevision();
65+
this.author = revision.author;
66+
this.repository = revision.repository;
67+
this.revision = revision.revision;
68+
this.date = revision.date;
69+
this.message = revision.message;
5470
// First check the type of the changement ofthe entry,
5571
// for it implies which type of info
5672
// we'll be able to extract.
@@ -60,7 +76,7 @@ public SubversionDocument(SVNLogEntryPath entryPath, SVNRepository repository, l
6076
|| change == 'M') {
6177
SVNDirEntry dirEntry = repository.info(
6278
entryPath.getPath(),
63-
revision
79+
revisionNumber
6480
);
6581
// ...and init a SubversionDocument to add to the revision
6682
this.content = SubversionCrawler.getContent(dirEntry, repository);

src/main/java/org/elasticsearch/river/subversion/mapping/SubversionDocumentMapping.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ public static XContentBuilder getInstance() throws IOException {
6666
.endObject()
6767
.endObject()
6868
.endObject()
69+
.startObject("fullname")
70+
.field("type", "multi_field")
71+
.startObject("fields")
72+
.startObject("fullname")
73+
.field("type", "string")
74+
.field("index", "analyzed")
75+
.endObject()
76+
.startObject("untouched")
77+
.field("type", "string")
78+
.field("index", "not_analyzed")
79+
.endObject()
80+
.endObject()
81+
.endObject()
6982
.startObject("size")
7083
.field("type", "integer")
7184
.field("index", "not_analyzed")
@@ -95,6 +108,36 @@ public static XContentBuilder getInstance() throws IOException {
95108
.endObject()
96109
.endObject()
97110
.endObject()
111+
.startObject("author")
112+
.field("type", "multi_field")
113+
.startObject("fields")
114+
.startObject("author")
115+
.field("type", "string")
116+
.field("index", "analyzed")
117+
.endObject()
118+
.startObject("untouched")
119+
.field("type", "string")
120+
.field("index", "not_analyzed")
121+
.endObject()
122+
.endObject()
123+
.endObject()
124+
.startObject("repository")
125+
.field("type", "string")
126+
.field("index", "not_analyzed")
127+
.endObject()
128+
.startObject("revision")
129+
.field("type", "long")
130+
.field("index", "not_analyzed")
131+
.endObject()
132+
.startObject("date")
133+
.field("type", "date")
134+
.field("format", "date_time")
135+
.field("index", "analyzed")
136+
.endObject()
137+
.startObject("message")
138+
.field("type", "string")
139+
.field("index", "analyzed")
140+
.endObject()
98141
.endObject()
99142
.endObject()
100143
.endObject();

src/test/resources/document.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
2-
"path": "/module2/trunk/playlist.txt",
2+
"path": "/module2/trunk",
33
"name": "playlist.txt",
44
"size": 88,
55
"change": "M",
66
"content": "Hey, maybe I\u0027ll try this Metal Gear Solid series the internet won\u0027t stop arguing about.\n",
7-
"from": -1
7+
"from": -1,
8+
"author": "Pascal.Lombard",
9+
"repository": "/home/Pascal.Lombard/Workspace/workspace-git/SubversionRiver/target/test-classes/TEST_REPOS",
10+
"revision": 6,
11+
"date": "2013-02-09T11:00:30.561+0100",
12+
"message": "what the hell ?",
13+
"fullname": "/module2/trunk/playlist.txt"
814
}

0 commit comments

Comments
 (0)