Skip to content

Commit 5a06757

Browse files
committed
Add integration tests
Closes #36. (cherry picked from commit f2c83df)
1 parent dcfbeeb commit 5a06757

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/java/org/elasticsearch/index/analysis/KuromojiIntegrationTests.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919
package org.elasticsearch.index.analysis;
2020

2121
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
22+
import org.elasticsearch.action.search.SearchResponse;
2223
import org.elasticsearch.common.settings.ImmutableSettings;
2324
import org.elasticsearch.common.settings.Settings;
25+
import org.elasticsearch.common.xcontent.XContentBuilder;
26+
import org.elasticsearch.index.query.QueryBuilders;
2427
import org.elasticsearch.plugins.PluginsService;
2528
import org.elasticsearch.test.ElasticsearchIntegrationTest;
2629
import org.junit.Test;
2730

31+
import java.io.IOException;
2832
import java.util.concurrent.ExecutionException;
2933

34+
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
3035
import static org.hamcrest.CoreMatchers.is;
3136
import static org.hamcrest.CoreMatchers.notNullValue;
3237

@@ -56,4 +61,31 @@ public void testKuromojiAnalyzer() throws ExecutionException, InterruptedExcepti
5661
assertThat(response.getTokens().get(i).getTerm(), is(expectedTokens[i]));
5762
}
5863
}
64+
65+
@Test
66+
public void testKuromojiAnalyzerInMapping() throws ExecutionException, InterruptedException, IOException {
67+
createIndex("test");
68+
ensureGreen("test");
69+
final XContentBuilder mapping = jsonBuilder().startObject()
70+
.startObject("type")
71+
.startObject("properties")
72+
.startObject("foo")
73+
.field("type", "string")
74+
.field("analyzer", "kuromoji")
75+
.endObject()
76+
.endObject()
77+
.endObject()
78+
.endObject();
79+
80+
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
81+
82+
index("test", "type", "1", "foo", "JR新宿駅の近くにビールを飲みに行こうか");
83+
refresh();
84+
85+
SearchResponse response = client().prepareSearch("test").setQuery(
86+
QueryBuilders.matchQuery("foo", "jr")
87+
).execute().actionGet();
88+
89+
assertThat(response.getHits().getTotalHits(), is(1L));
90+
}
5991
}

0 commit comments

Comments
 (0)