Permalink
Browse files

support elasticsearch > 0.20.2

  • Loading branch information...
1 parent 1dfa578 commit a1272bcf5e692bdf3801ec88862b07f84dfeb8c4 @medcl committed Feb 12, 2013
View
@@ -6,7 +6,7 @@ http://s.medcl.net/?query=Search+API++Search+Type
1.download lexical files (https://github.com/downloads/medcl/elasticsearch-carrot2/config.zip) ,put them into the config folder.
-2.bin/plugin install medcl/elasticsearch-carrot2/1.1
+2.bin/plugin install medcl/elasticsearch-carrot2/1.1.1
have fun.
View
@@ -4,11 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>elasticsearch</groupId>
- <artifactId>elasticsearch-carrot2</artifactId>
- <version>1.0.1</version>
+ <artifactId>elasticsearch-tools-carrot2</artifactId>
+ <version>1.1.3</version>
<properties>
- <elasticsearch.version>0.19.11</elasticsearch.version>
+ <elasticsearch.version>0.20.2</elasticsearch.version>
</properties>
<repositories>
@@ -2,11 +2,13 @@
import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchOperationThreading;
+import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
-import org.elasticsearch.action.support.BaseRequestBuilder;
import org.elasticsearch.client.Client;
+import org.elasticsearch.client.internal.InternalClient;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
@@ -29,28 +31,25 @@
* Date: 3/20/12
* Time: 2:05 PM
*/
-public class Carrot2RequestBuilder extends BaseRequestBuilder<Carrot2Request,Carrot2Response> {
+public class Carrot2RequestBuilder extends ActionRequestBuilder<Carrot2Request,Carrot2Response,Carrot2RequestBuilder> {
protected final ESLogger logger= Loggers.getLogger(getClass());
private Carrot2SourceBuilder sourceBuilder;
public Carrot2RequestBuilder(Client client) {
- super(client, new Carrot2Request());
- logger.info("carrot2 request builder construct");
+ super((InternalClient) client, new Carrot2Request());
}
@Override
public ListenableActionFuture<Carrot2Response> execute() {
- logger.info("carrot2 request builder execute1");
return super.execute();
}
@Override
public void execute(ActionListener<Carrot2Response> carrot2ResponseActionListener) {
- logger.info("carrot2 request builder execute2");
super.execute(carrot2ResponseActionListener);
}
-
-
+
+
/**
* Sets the indices the search will be executed on.
@@ -179,14 +178,6 @@ public Carrot2RequestBuilder setOperationThreading(String operationThreading) {
}
/**
- * Should the listener be called on a separate thread if needed.
- */
- public Carrot2RequestBuilder setListenerThreaded(boolean listenerThreaded) {
- request.listenerThreaded(listenerThreaded);
- return this;
- }
-
- /**
* Constructs a new search source builder with a search query.
*
* @see org.elasticsearch.index.query.QueryBuilders
@@ -733,8 +724,24 @@ protected void doExecute(ActionListener<Carrot2Response> listener) {
if (sourceBuilder != null) {
request.source( sourceBuilder());
}
- //TODO client.execute(request, listener);
- client.search(request);
+ doInnerExecute(new ActionListener<SearchResponse>() {
+ @Override
+ public void onResponse(SearchResponse searchResponse) {
+
+ }
+
+ @Override
+ public void onFailure(Throwable e) {
+
+ }
+ });
+ }
+
+ protected void doInnerExecute(ActionListener<SearchResponse> listener) {
+ if (sourceBuilder != null) {
+ request.source( sourceBuilder());
+ }
+ ((Client) client).search(request, listener);
}
private Carrot2SourceBuilder sourceBuilder() {
@@ -1,13 +1,12 @@
package org.elasticsearch.plugin.infinitbyte;
-import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.common.xcontent.XContentFactory;
@@ -27,7 +26,7 @@
* Date: 3/20/12
* Time: 1:58 PM
*/
-public class Carrot2Response implements ActionResponse,ToXContent {
+public class Carrot2Response extends SearchResponse {
protected final ESLogger logger= Loggers.getLogger(getClass());
public Carrot2Response(InternalSearchResponse internalResponse, String scrollId, int totalShards, int successfulShards, long tookInMillis, ShardSearchFailure[] shardFailures) {
@@ -58,12 +58,8 @@
@Inject
protected Carrot2RestAction(Settings settings, Client client, RestController restController) {
super(settings, client);
-
environment=new Environment(settings);
-// logger.debug(environment.configFile().getPath());
-// logger.debug(environment.configFile().getAbsolutePath());
-
restController.registerHandler(RestRequest.Method.POST, "/{index}/{type}/_carrot2", this);
restController.registerHandler(RestRequest.Method.POST, "/{index}/{type}/_carrot2/{algorithm}", this);
restController.registerHandler(RestRequest.Method.POST, "/{index}/_carrot2", this);
@@ -132,8 +128,6 @@ public void onResponse(SearchResponse response) {
}
for (SearchHit hit : response.getHits()) {
-
-
Map<String, Object> objectMap = hit.sourceAsMap();
if(objectMap==null){
if(hit.fields()!=null){

0 comments on commit a1272bc

Please sign in to comment.