Skip to content

Commit 2a514b4

Browse files
committed
Merge pull request #7 from mschumann/master
update to elasticsearch 1.2.1
2 parents 7a78255 + 47f7b1d commit 2a514b4

File tree

6 files changed

+36
-52
lines changed

6 files changed

+36
-52
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ES version Plugin Release date Command
1818
0.90.5 1.3.0 Oct 16, 2013 ./bin/plugin --install termlist --url http://bit.ly/1bzHfIl
1919
0.90.7 1.4.0 Dec 20, 2013 ./bin/plugin --install termlist --url http://bit.ly/1c70ICf
2020
1.0.0.RC1 1.0.0.RC1.1 Jan 16, 2014 ./bin/plugin --install termlist --url http://bit.ly/1dSIzoW
21+
1.2.1 1.2.1
2122
============= =========== ================= ===========================================================
2223

2324
Do not forget to restart the node after installing.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.xbib.elasticsearch.plugin</groupId>
88
<artifactId>elasticsearch-index-termlist</artifactId>
9-
<version>1.0.0.RC1.1</version>
9+
<version>1.2.1</version>
1010

1111
<packaging>jar</packaging>
1212

@@ -44,7 +44,7 @@
4444
<properties>
4545
<github.global.server>github</github.global.server>
4646
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
47-
<elasticsearch.version>1.0.0.RC1</elasticsearch.version>
47+
<elasticsearch.version>1.2.1</elasticsearch.version>
4848
</properties>
4949

5050
<dependencies>

src/main/java/org/xbib/elasticsearch/action/termlist/TermlistRequest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11

22
package org.xbib.elasticsearch.action.termlist;
33

4+
import java.io.IOException;
5+
46
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
5-
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
67
import org.elasticsearch.common.io.stream.StreamInput;
78
import org.elasticsearch.common.io.stream.StreamOutput;
89

9-
import java.io.IOException;
10-
1110
public class TermlistRequest extends BroadcastOperationRequest<TermlistRequest> {
1211

1312
private String field;
@@ -23,7 +22,6 @@ public class TermlistRequest extends BroadcastOperationRequest<TermlistRequest>
2322

2423
public TermlistRequest(String... indices) {
2524
super(indices);
26-
operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);
2725
}
2826

2927
public void setField(String field) {

src/main/java/org/xbib/elasticsearch/action/termlist/TransportTermlistAction.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11

22
package org.xbib.elasticsearch.action.termlist;
33

4+
import java.io.IOException;
5+
import java.util.Comparator;
6+
import java.util.List;
7+
import java.util.Map;
8+
import java.util.SortedMap;
9+
import java.util.TreeMap;
10+
import java.util.concurrent.atomic.AtomicReferenceArray;
11+
412
import org.apache.lucene.index.Fields;
513
import org.apache.lucene.index.IndexReader;
614
import org.apache.lucene.index.MultiFields;
715
import org.apache.lucene.index.Terms;
816
import org.apache.lucene.index.TermsEnum;
917
import org.apache.lucene.util.BytesRef;
10-
1118
import org.elasticsearch.ElasticsearchException;
1219
import org.elasticsearch.action.ShardOperationFailedException;
1320
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
@@ -27,14 +34,6 @@
2734
import org.elasticsearch.threadpool.ThreadPool;
2835
import org.elasticsearch.transport.TransportService;
2936

30-
import java.io.IOException;
31-
import java.util.Comparator;
32-
import java.util.List;
33-
import java.util.Map;
34-
import java.util.SortedMap;
35-
import java.util.TreeMap;
36-
import java.util.concurrent.atomic.AtomicReferenceArray;
37-
3837
import static org.elasticsearch.common.collect.Lists.newLinkedList;
3938

4039
/**
@@ -173,7 +172,7 @@ protected ShardTermlistResponse shardOperation(ShardTermlistRequest request) thr
173172
} catch (IOException ex) {
174173
throw new ElasticsearchException(ex.getMessage(), ex);
175174
} finally {
176-
searcher.release();
175+
searcher.close();
177176
}
178177
}
179178

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11

22
package org.xbib.elasticsearch.rest.action.termlist;
33

4-
import java.io.IOException;
54
import java.util.Map;
65

7-
import org.elasticsearch.action.ActionListener;
86
import org.elasticsearch.client.Client;
97
import org.elasticsearch.common.Strings;
108
import org.elasticsearch.common.inject.Inject;
119
import org.elasticsearch.common.settings.Settings;
1210
import org.elasticsearch.common.xcontent.XContentBuilder;
1311
import org.elasticsearch.rest.BaseRestHandler;
12+
import org.elasticsearch.rest.BytesRestResponse;
1413
import org.elasticsearch.rest.RestChannel;
1514
import org.elasticsearch.rest.RestController;
1615
import org.elasticsearch.rest.RestRequest;
17-
import org.elasticsearch.rest.XContentRestResponse;
18-
import org.elasticsearch.rest.XContentThrowableRestResponse;
19-
import org.elasticsearch.rest.action.support.RestXContentBuilder;
20-
16+
import org.elasticsearch.rest.RestResponse;
17+
import org.elasticsearch.rest.action.support.RestBuilderListener;
2118
import org.xbib.elasticsearch.action.termlist.TermInfo;
2219
import org.xbib.elasticsearch.action.termlist.TermlistAction;
2320
import org.xbib.elasticsearch.action.termlist.TermlistRequest;
@@ -44,38 +41,27 @@ public void handleRequest(final RestRequest request, final RestChannel channel)
4441
termlistRequest.setSize(request.paramAsInt("size", 0));
4542
termlistRequest.setWithDocFreq(request.paramAsBoolean("docfreqs", false));
4643
termlistRequest.setWithTotalFreq(request.paramAsBoolean("totalfreqs", false));
47-
client.execute(TermlistAction.INSTANCE, termlistRequest, new ActionListener<TermlistResponse>() {
44+
client.execute(TermlistAction.INSTANCE, termlistRequest, new RestBuilderListener<TermlistResponse>(channel) {
4845

49-
public void onResponse(TermlistResponse response) {
50-
try {
51-
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
52-
builder.startObject();
53-
buildBroadcastShardsHeader(builder, response);
54-
builder.startArray("terms");
55-
for (Map.Entry<String,TermInfo> t : response.getTermlist().entrySet()) {
56-
builder.startObject().field("name", t.getKey());
57-
if (t.getValue().getDocFreq() != null) {
58-
builder.field("docfreq", t.getValue().getDocFreq());
59-
}
60-
if (t.getValue().getTotalFreq() != null) {
61-
builder.field("totalfreq", t.getValue().getTotalFreq());
62-
}
63-
builder.endObject();
46+
@Override
47+
public RestResponse buildResponse(TermlistResponse response, XContentBuilder builder) throws Exception {
48+
builder.startObject();
49+
buildBroadcastShardsHeader(builder, response);
50+
builder.startArray("terms");
51+
for (Map.Entry<String,TermInfo> t : response.getTermlist().entrySet()) {
52+
builder.startObject().field("name", t.getKey());
53+
if (t.getValue().getDocFreq() != null) {
54+
builder.field("docfreq", t.getValue().getDocFreq());
6455
}
65-
builder.endArray().endObject();
66-
channel.sendResponse(new XContentRestResponse(request, OK, builder));
67-
} catch (Exception e) {
68-
onFailure(e);
69-
}
70-
}
71-
72-
public void onFailure(Throwable e) {
73-
try {
74-
channel.sendResponse(new XContentThrowableRestResponse(request, e));
75-
} catch (IOException e1) {
76-
logger.error("Failed to send failure response", e1);
56+
if (t.getValue().getTotalFreq() != null) {
57+
builder.field("totalfreq", t.getValue().getTotalFreq());
58+
}
59+
builder.endObject();
7760
}
78-
}
61+
builder.endArray().endObject();
62+
63+
return new BytesRestResponse(OK, builder);
64+
}
7965
});
8066
}
8167
}

src/test/java/org/xbib/elasticsearch/plugin/termlist/SimpleTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void stopNode() {
4545
@Test
4646
public void assertPluginLoaded() {
4747
NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo()
48-
.clear().setPlugin(true).get();
48+
.clear().setPlugins(true).get();
4949
logger.info("{}", nodesInfoResponse);
5050
assertEquals(nodesInfoResponse.getNodes().length, 1);
5151
assertNotNull(nodesInfoResponse.getNodes()[0].getPlugins().getInfos());

0 commit comments

Comments
 (0)