Skip to content

Commit

Permalink
升级ElasticSearch从1.2.1到1.4.2,升级Lucene从4.9.0到4.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed Feb 10, 2015
1 parent cdca6f7 commit 90b91dd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 90 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ dependencies {
testCompile (
'junit:junit:4.11',
'org.hamcrest:hamcrest-library:1.3',
'org.apache.lucene:lucene-test-framework:4.9.0',
'org.apache.lucene:lucene-queryparser:4.9.0',
'org.elasticsearch:elasticsearch:1.2.1:tests',
'com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.1.3'
'org.apache.lucene:lucene-test-framework:4.10.2',
'org.apache.lucene:lucene-queryparser:4.10.2',
'org.elasticsearch:elasticsearch:1.4.2:tests',
'com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.1.11'
)

compile (
'org.slf4j:slf4j-api:1.6.4',
'org.apache.lucene:lucene-core:4.9.0',
'org.apache.lucene:lucene-analyzers-common:4.9.0',
'org.elasticsearch:elasticsearch:1.2.1',
'org.apache.lucene:lucene-core:4.10.2',
'org.apache.lucene:lucene-analyzers-common:4.10.2',
'org.elasticsearch:elasticsearch:1.4.2',
'redis.clients:jedis:2.5.1'
)

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@

<junit.version>4.11</junit.version>
<hamcrest.version>1.3</hamcrest.version>
<randomizedtesting.version>2.1.3</randomizedtesting.version>
<randomizedtesting.version>2.1.11</randomizedtesting.version>
<slf4j-api.version>1.6.4</slf4j-api.version>
<logback-classic.version>0.9.28</logback-classic.version>
<lucene.version>4.9.0</lucene.version>
<elasticsearch.version>1.2.1</elasticsearch.version>
<lucene.version>4.10.2</lucene.version>
<elasticsearch.version>1.4.2</elasticsearch.version>
<jedis.version>2.5.1</jedis.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apdplat.word.lucene.ChineseWordAnalyzer;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
Expand All @@ -41,7 +44,7 @@
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.junit.Test;

import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.analysis.AnalysisModule;
import org.elasticsearch.index.analysis.AnalysisService;
import org.elasticsearch.index.analysis.TokenizerFactory;
Expand All @@ -53,21 +56,21 @@
* @author 杨尚川
*/
public class ChineseWordIndicesAnalysisTest {

private static final Settings SETTINGS = ImmutableSettings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
@Test
public void testChineseWordIndicesAnalysis() throws IOException {
Index index = new Index("test");

Injector parentInjector = new ModulesBuilder()
.add(new SettingsModule(EMPTY_SETTINGS),
new EnvironmentModule(new Environment(EMPTY_SETTINGS)),
.add(new SettingsModule(SETTINGS),
new EnvironmentModule(new Environment(SETTINGS)),
new IndicesAnalysisModule())
.createInjector();

Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, EMPTY_SETTINGS),
new IndexSettingsModule(index, SETTINGS),
new IndexNameModule(index),
new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class))
new AnalysisModule(SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class))
.addProcessor(new ChineseWordAnalysisBinderProcessor()))
.createChildInjector(parentInjector);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void test3() {
sentences.add("张掖市明乐县");
sentences.add("中华人民共和国万岁万岁万万岁");
sentences.add("word是一个中文分词项目,作者是杨尚川,杨尚川的英文名叫ysc");
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_9, analyzer);
IndexWriterConfig config = new IndexWriterConfig(Version.LATEST, analyzer);
config.setUseCompoundFile(false);
File index = new File("target/indexes");
Utils.deleteDir(index);
Expand All @@ -146,7 +146,7 @@ public void test3() {
try (Directory directory = new SimpleFSDirectory(index);
DirectoryReader directoryReader = DirectoryReader.open(directory)) {
IndexSearcher indexSearcher = new IndexSearcher(directoryReader);
QueryParser queryParser = new QueryParser(Version.LUCENE_4_9, "text", analyzer);
QueryParser queryParser = new QueryParser("text", analyzer);
Query query = queryParser.parse("text:杨尚川");
TopDocs docs = indexSearcher.search(query, Integer.MAX_VALUE);
assertEquals(2, docs.totalHits);
Expand Down

0 comments on commit 90b91dd

Please sign in to comment.