Skip to content

Commit 0e2384e

Browse files
author
Masaru Hasegawa
committed
Initial import
0 parents  commit 0e2384e

18 files changed

+1129
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
*.class
3+
*.iml
4+
/target
5+
/.idea
6+
/data
7+

NOTICE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This product includes software developed by:
2+
- Elasticsearch (http://www.elasticsearch.org)

README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Completion suggester for Japanese for Elasticsearch
2+
==================================
3+
4+
This plugin includes:
5+
* "kuromoji_suggest" tokenizer, extension for Japanese (kuromoji) Analysis plugin (https://github.com/elasticsearch/elasticsearch-analysis-kuromoji) to enable query completion.
6+
* "japanese_completion" suggester, customized completion suggester for Japanese.
7+
8+
You need to install a version matching your Elasticsearch version:
9+
10+
| elasticsearch | Kuromoji Analysis Suggest Plugin |
11+
|---------------|-----------------------------|
12+
| es-1.4 | 0.9 |
13+
14+
15+
## Prerequisites
16+
* analysis-kuromoji plugin (https://github.com/elasticsearch/elasticsearch-analysis-kuromoji)
17+
* (Optional) To deal with full-width and half-width characters, elasticsearch-analysis-icu(https://github.com/elasticsearch/elasticsearch-analysis-icu)
18+
19+
## Installation
20+
In order to install the plugin, run:
21+
22+
```sh
23+
mvn -DskipTests package
24+
25+
# In elasticsearch home directory
26+
bin/plugin -u https://github.com/masaruh/elasticsearch-japanese-suggester/releases/download/0.9/elasticsearch-japanese-suggester-0.9.zip -i japanese-suggester
27+
```
28+
29+
### Example
30+
Use expand=true for indexing and expand=false for searching.
31+
```sh
32+
curl -XPUT 'http://localhost:9200/suggest_sample/' -d'
33+
{
34+
"index": {
35+
"analysis": {
36+
"analyzer": {
37+
"kuromoji_suggest_index":{
38+
"tokenizer":"kuromoji_suggest_index"
39+
},
40+
"kuromoji_suggest_search":{
41+
"tokenizer":"kuromoji_suggest_search"
42+
}
43+
},
44+
45+
"tokenizer":{
46+
"kuromoji_suggest_index":{
47+
"type": "kuromoji_suggest",
48+
"expand":true
49+
},
50+
"kuromoji_suggest_search":{
51+
"type": "kuromoji_suggest",
52+
"expand":false
53+
}
54+
}
55+
}
56+
}
57+
}
58+
'
59+
```
60+
61+
Then add completion suggester configuration:
62+
```sh
63+
curl -XPUT 'http://localhost:9200/suggest_sample/_mapping' -d'
64+
{
65+
"test": {
66+
"properties": {
67+
"suggest": {
68+
"type": "japanese_completion",
69+
"index_analyzer": "kuromoji_suggest_index",
70+
"search_analyzer": "kuromoji_suggest_search",
71+
"payloads": true
72+
}
73+
}
74+
}
75+
}
76+
'
77+
```
78+
79+
Feed document:
80+
```sh
81+
curl -XPUT 'http://localhost:9200/suggest_sample/test/1' -d'
82+
{
83+
"suggest":"東京駅"
84+
}
85+
```
86+
87+
And search:
88+
```sh
89+
curl -XPOST 'http://localhost:9200/suggest_sample/_suggest' -d'
90+
{
91+
"suggest" : {
92+
"text" : "とうk",
93+
"japanese_completion" : {
94+
"field" : "suggest"
95+
}
96+
}
97+
}
98+
'
99+
100+
{
101+
"_shards" : {
102+
"total" : 5,
103+
"successful" : 5,
104+
"failed" : 0
105+
},
106+
"suggest" : [ {
107+
"text" : "とうk",
108+
"offset" : 0,
109+
"length" : 3,
110+
"options" : [ {
111+
"text" : "東京駅",
112+
"score" : 1.0
113+
} ]
114+
} ]
115+
}
116+
117+
```
118+
119+
120+
121+
License
122+
-------
123+
See LICENSE.txt

pom.xml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.elasticsearch</groupId>
8+
<artifactId>elasticsearch-japanese-suggester</artifactId>
9+
<version>0.9</version>
10+
11+
12+
<packaging>jar</packaging>
13+
14+
<properties>
15+
<elasticsearch.version>1.4.0</elasticsearch.version>
16+
<lucene.version>4.10.2</lucene.version>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.apache.lucene</groupId>
22+
<artifactId>lucene-test-framework</artifactId>
23+
<version>${lucene.version}</version>
24+
<scope>test</scope>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.elasticsearch</groupId>
29+
<artifactId>elasticsearch</artifactId>
30+
<version>${elasticsearch.version}</version>
31+
<scope>compile</scope>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.apache.lucene</groupId>
36+
<artifactId>lucene-analyzers-kuromoji</artifactId>
37+
<version>${lucene.version}</version>
38+
<scope>compile</scope>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>com.fasterxml.jackson.core</groupId>
43+
<artifactId>jackson-databind</artifactId>
44+
<version>2.4.2</version>
45+
<scope>compile</scope>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>junit</groupId>
50+
<artifactId>junit</artifactId>
51+
<version>4.11</version>
52+
<scope>test</scope>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>org.hamcrest</groupId>
57+
<artifactId>hamcrest-all</artifactId>
58+
<version>1.3</version>
59+
<scope>test</scope>
60+
</dependency>
61+
62+
<dependency>
63+
<groupId>org.elasticsearch</groupId>
64+
<artifactId>elasticsearch</artifactId>
65+
<version>${elasticsearch.version}</version>
66+
<type>test-jar</type>
67+
<scope>test</scope>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>com.carrotsearch.randomizedtesting</groupId>
72+
<artifactId>randomizedtesting-runner</artifactId>
73+
<version>2.1.10</version>
74+
<scope>test</scope>
75+
</dependency>
76+
77+
</dependencies>
78+
79+
<build>
80+
<plugins>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-compiler-plugin</artifactId>
84+
<version>2.3.2</version>
85+
<configuration>
86+
<source>1.7</source>
87+
<target>1.7</target>
88+
</configuration>
89+
</plugin>
90+
91+
<plugin>
92+
<artifactId>maven-assembly-plugin</artifactId>
93+
<version>2.3</version>
94+
<configuration>
95+
<appendAssemblyId>false</appendAssemblyId>
96+
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
97+
<descriptors>
98+
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
99+
</descriptors>
100+
</configuration>
101+
<executions>
102+
<execution>
103+
<phase>package</phase>
104+
<goals>
105+
<goal>single</goal>
106+
</goals>
107+
</execution>
108+
</executions>
109+
</plugin>
110+
</plugins>
111+
</build>
112+
</project>

src/main/assemblies/plugin.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<assembly>
3+
<id>plugin</id>
4+
<formats>
5+
<format>zip</format>
6+
</formats>
7+
<includeBaseDirectory>false</includeBaseDirectory>
8+
<dependencySets>
9+
<dependencySet>
10+
<outputDirectory>/</outputDirectory>
11+
<useProjectArtifact>true</useProjectArtifact>
12+
<useTransitiveFiltering>true</useTransitiveFiltering>
13+
<excludes>
14+
<exclude>org.elasticsearch:elasticsearch</exclude>
15+
</excludes>
16+
</dependencySet>
17+
<dependencySet>
18+
<outputDirectory>/</outputDirectory>
19+
<useProjectArtifact>true</useProjectArtifact>
20+
<useTransitiveFiltering>true</useTransitiveFiltering>
21+
<includes>
22+
<include>com.fasterxml.jackson.core:jackson-databind</include>
23+
</includes>
24+
</dependencySet>
25+
</dependencySets>
26+
</assembly>

0 commit comments

Comments
 (0)