From 627a86a608e1aefbc6ce5a22874f3416b38c1a82 Mon Sep 17 00:00:00 2001 From: Jun Ohtani Date: Sat, 18 Jan 2014 09:58:51 +0900 Subject: [PATCH] Update to elasticsearch 1.0.0.RC1 --- NOTICE | 2 +- README.md | 10 +++-- pom.xml | 6 +-- .../analyze/ExtendedAnalyzeRequest.java | 3 -- .../TransportExtendedAnalyzeAction.java | 38 +++++++++---------- .../analyze/RestExtendedAnalyzeAction.java | 5 +-- 6 files changed, 29 insertions(+), 35 deletions(-) diff --git a/NOTICE b/NOTICE index 2cf6f9d..575f325 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -Copyright 2013, Jun Ohtani +Copyright 2013-2014, Jun Ohtani Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/README.md b/README.md index 263ef8b..4aa3a5d 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,12 @@ And the plugin output tokens step by step. Similar functionality to Solr admin UI analysis page. -|Plugin |Elasticsearch |Release date| -|--------|---------------|------------| -|0.6.0 | 0.90.7->master| 2013-11-19 | -|0.5 | 0.90.7->master| 2013-11-14 | +|Plugin |Elasticsearch |Release date| +|---------|-------------------|------------| +|1.0.0.RC1| 1.0.0.RC1->master | 2014-01-18 | +|0.7.0 | 0.90.7->0.90 | 2013-11-28 | +|0.6.0 | 0.90.7->master | 2013-11-19 | +|0.5 | 0.90.7->master | 2013-11-14 | ### Feature diff --git a/pom.xml b/pom.xml index 7309bff..2ec2ca5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 info.johtani elasticsearch-extended-analyze - 0.8.0-SNAPSHOT + 1.0.0.RC1-SNAPSHOT jar Extend _analyze API plugin for ElasticSearch https://github.com/johtani/elasticsearch-extended-analyze @@ -28,8 +28,8 @@ - 0.90.7 - 4.5.1 + 1.0.0.RC1 + 4.6.0 diff --git a/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/ExtendedAnalyzeRequest.java b/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/ExtendedAnalyzeRequest.java index c275da1..51c4ddf 100644 --- a/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/ExtendedAnalyzeRequest.java +++ b/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/ExtendedAnalyzeRequest.java @@ -25,9 +25,6 @@ import static org.elasticsearch.action.ValidateActions.*; -/** - * TODO: extends AnalyzeRequest? this implement is not smart... - */ public class ExtendedAnalyzeRequest extends SingleCustomOperationRequest { private String index; diff --git a/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/TransportExtendedAnalyzeAction.java b/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/TransportExtendedAnalyzeAction.java index afbe8d5..1a8dd66 100644 --- a/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/TransportExtendedAnalyzeAction.java +++ b/src/main/java/info/johtani/elasticsearch/action/admin/indices/extended/analyze/TransportExtendedAnalyzeAction.java @@ -25,9 +25,8 @@ import org.apache.lucene.util.Attribute; import org.apache.lucene.util.AttributeReflector; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CollectionUtil; -import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.ElasticSearchIllegalArgumentException; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.ElasticsearchIllegalArgumentException; import org.elasticsearch.action.support.single.custom.TransportSingleCustomOperationAction; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -53,7 +52,6 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -118,7 +116,7 @@ protected ShardsIterator shards(ClusterState state, ExtendedAnalyzeRequest reque } @Override - protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, int shardId) throws ElasticSearchException { + protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, int shardId) throws ElasticsearchException { IndexService indexService = null; if (request.index() != null) { indexService = indicesService.indexServiceSafe(request.index()); @@ -128,12 +126,12 @@ protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, String field = null; if (request.field() != null) { if (indexService == null) { - throw new ElasticSearchIllegalArgumentException("No index provided, and trying to analyzer based on a specific field which requires the index parameter"); + throw new ElasticsearchIllegalArgumentException("No index provided, and trying to analyzer based on a specific field which requires the index parameter"); } FieldMapper fieldMapper = indexService.mapperService().smartNameFieldMapper(request.field()); if (fieldMapper != null) { if (fieldMapper.isNumeric()) { - throw new ElasticSearchIllegalArgumentException("Can't process field [" + request.field() + "], Analysis requests are not supported on numeric fields"); + throw new ElasticsearchIllegalArgumentException("Can't process field [" + request.field() + "], Analysis requests are not supported on numeric fields"); } analyzer = fieldMapper.indexAnalyzer(); field = fieldMapper.names().indexName(); @@ -154,20 +152,20 @@ protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, analyzer = indexService.analysisService().analyzer(request.analyzer()); } if (analyzer == null) { - throw new ElasticSearchIllegalArgumentException("failed to find analyzer [" + request.analyzer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find analyzer [" + request.analyzer() + "]"); } } else if (request.tokenizer() != null) { TokenizerFactory tokenizerFactory; if (indexService == null) { TokenizerFactoryFactory tokenizerFactoryFactory = indicesAnalysisService.tokenizerFactoryFactory(request.tokenizer()); if (tokenizerFactoryFactory == null) { - throw new ElasticSearchIllegalArgumentException("failed to find global tokenizer under [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find global tokenizer under [" + request.tokenizer() + "]"); } tokenizerFactory = tokenizerFactoryFactory.create(request.tokenizer(), ImmutableSettings.Builder.EMPTY_SETTINGS); } else { tokenizerFactory = indexService.analysisService().tokenizer(request.tokenizer()); if (tokenizerFactory == null) { - throw new ElasticSearchIllegalArgumentException("failed to find tokenizer under [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find tokenizer under [" + request.tokenizer() + "]"); } } TokenFilterFactory[] tokenFilterFactories = new TokenFilterFactory[0]; @@ -178,17 +176,17 @@ protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, if (indexService == null) { TokenFilterFactoryFactory tokenFilterFactoryFactory = indicesAnalysisService.tokenFilterFactoryFactory(tokenFilterName); if (tokenFilterFactoryFactory == null) { - throw new ElasticSearchIllegalArgumentException("failed to find global token filter under [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find global token filter under [" + request.tokenizer() + "]"); } tokenFilterFactories[i] = tokenFilterFactoryFactory.create(tokenFilterName, ImmutableSettings.Builder.EMPTY_SETTINGS); } else { tokenFilterFactories[i] = indexService.analysisService().tokenFilter(tokenFilterName); if (tokenFilterFactories[i] == null) { - throw new ElasticSearchIllegalArgumentException("failed to find token filter under [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find token filter under [" + request.tokenizer() + "]"); } } if (tokenFilterFactories[i] == null) { - throw new ElasticSearchIllegalArgumentException("failed to find token filter under [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find token filter under [" + request.tokenizer() + "]"); } } } @@ -200,17 +198,17 @@ protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, if (indexService == null) { CharFilterFactoryFactory charFilterFactoryFactory = indicesAnalysisService.charFilterFactoryFactory(charFilterName); if (charFilterFactoryFactory == null) { - throw new ElasticSearchIllegalArgumentException("failed to find global char filter top [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find global char filter top [" + request.tokenizer() + "]"); } charFilterFactories[i] = charFilterFactoryFactory.create(charFilterName, ImmutableSettings.Builder.EMPTY_SETTINGS); } else { charFilterFactories[i] = indexService.analysisService().charFilter(charFilterName); if (charFilterFactories[i] == null) { - throw new ElasticSearchIllegalArgumentException("failed to find char filter top [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find char filter top [" + request.tokenizer() + "]"); } } if (charFilterFactories[i] == null) { - throw new ElasticSearchIllegalArgumentException("failed to find char filter top [" + request.tokenizer() + "]"); + throw new ElasticsearchIllegalArgumentException("failed to find char filter top [" + request.tokenizer() + "]"); } } } @@ -224,7 +222,7 @@ protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, } } if (analyzer == null) { - throw new ElasticSearchIllegalArgumentException("failed to find analyzer"); + throw new ElasticsearchIllegalArgumentException("failed to find analyzer"); } ExtendedAnalyzeResponse response = buildResponse(request, analyzer, closeAnalyzer, field); @@ -235,7 +233,6 @@ protected ExtendedAnalyzeResponse shardOperation(ExtendedAnalyzeRequest request, private ExtendedAnalyzeResponse buildResponse(ExtendedAnalyzeRequest request, Analyzer analyzer, boolean closeAnalyzer, String field) { ExtendedAnalyzeResponse response = new ExtendedAnalyzeResponse(); TokenStream stream = null; - List tokens = null; final Set includeAttibutes = Sets.newHashSet(); if (request.attributes() != null && request.attributes().length > 0) { for (String attribute : request.attributes()) { @@ -274,7 +271,6 @@ private ExtendedAnalyzeResponse buildResponse(ExtendedAnalyzeRequest request, An for (int i = 0; i < tokenfilters.length; i++) { stream = createStackedTokenStream(source, tokenizer, tokenfilters, i + 1); response.addTokenfilter(new ExtendedAnalyzeResponse.ExtendedAnalyzeTokenList(tokenfilters[i].name(), processAnalysis(stream, includeAttibutes))); - //FIXME implement freezeStage stream.close(); } @@ -293,7 +289,7 @@ private ExtendedAnalyzeResponse buildResponse(ExtendedAnalyzeRequest request, An } } catch (IOException e) { - throw new ElasticSearchException("failed to analyze", e); + throw new ElasticsearchException("failed to analyze", e); } finally { if (stream != null) { try { @@ -331,7 +327,7 @@ private String writeCharStream(Reader input) { try { len = input.read(buf, 0, BUFFER_SIZE); } catch (IOException e) { - throw new ElasticSearchException("failed to analyze (charfiltering)", e); + throw new ElasticsearchException("failed to analyze (charfiltering)", e); } if (len > 0) sb.append(buf, 0, len); diff --git a/src/main/java/info/johtani/elasticsearch/rest/action/admin/indices/analyze/RestExtendedAnalyzeAction.java b/src/main/java/info/johtani/elasticsearch/rest/action/admin/indices/analyze/RestExtendedAnalyzeAction.java index 9151d71..fb6241a 100644 --- a/src/main/java/info/johtani/elasticsearch/rest/action/admin/indices/analyze/RestExtendedAnalyzeAction.java +++ b/src/main/java/info/johtani/elasticsearch/rest/action/admin/indices/analyze/RestExtendedAnalyzeAction.java @@ -15,9 +15,8 @@ */ package info.johtani.elasticsearch.rest.action.admin.indices.analyze; -import org.elasticsearch.ElasticSearchIllegalArgumentException; +import org.elasticsearch.ElasticsearchIllegalArgumentException; import org.elasticsearch.action.ActionListener; -import info.johtani.elasticsearch.action.admin.indices.extended.analyze.*; import info.johtani.elasticsearch.action.admin.indices.extended.analyze.ExtendedAnalyzeAction; import info.johtani.elasticsearch.action.admin.indices.extended.analyze.ExtendedAnalyzeRequest; import info.johtani.elasticsearch.action.admin.indices.extended.analyze.ExtendedAnalyzeResponse; @@ -55,7 +54,7 @@ public void handleRequest(final RestRequest request, final RestChannel channel) } if (text == null) { try { - channel.sendResponse(new XContentThrowableRestResponse(request, new ElasticSearchIllegalArgumentException("text is missing"))); + channel.sendResponse(new XContentThrowableRestResponse(request, new ElasticsearchIllegalArgumentException("text is missing"))); } catch (IOException e1) { logger.warn("Failed to send response", e1); }