|
1 |
| -# Voikko Analysis for Elasticsearch |
2 |
| - |
3 |
| -The Voikko Analysis plugin provides Finnish language analysis using [Voikko](http://voikko.puimula.org/). |
4 |
| - |
5 |
| -## Supported versions |
6 |
| - |
7 |
| -| Plugin version | Elasticsearch version | |
8 |
| -| -------------- | ----------------------| |
9 |
| -| [0.5.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.5.0/README.md) | 5.1.1 | |
10 |
| -| [0.4.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.4.0/README.md) | 2.2.1 | |
11 |
| -| [0.3.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.3.0/README.md) | 1.5.2 | |
12 |
| - |
13 |
| -If you are not installing the latest version, follow the links in the table to see installation instructions for the old version. |
14 |
| - |
15 |
| -## Installing |
16 |
| - |
17 |
| -### Installing Voikko |
18 |
| - |
19 |
| -The plugin needs `libvoikko` shared library to work. Details of installing the library varies |
20 |
| -based on operating system. In Debian based systems `apt-get install libvoikko1` should work. |
21 |
| - |
22 |
| -Next, you'll need to download [morpho dictionary](http://www.puimula.org/htp/testing/voikko-snapshot/dict-morpho.zip) |
23 |
| -(for libvoikko version 4.0+, use [morpho dict v5](http://www.puimula.org/htp/testing/voikko-snapshot-v5/dict-morpho.zip) |
24 |
| -instead). |
25 |
| -Unzip this into Voikko's dictionary directory (e.g. `/usr/lib/voikko` in Debian) or into a directory you specify with |
26 |
| -`dictionaryPath` configuration property. |
27 |
| - |
28 |
| -### Installing the plugin |
29 |
| - |
30 |
| -Finally, to install the plugin, run: |
31 |
| - |
32 |
| -``` |
33 |
| -bin/elasticsearch-plugin install https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/releases/download/v0.5.0/elasticsearch-analysis-voikko-0.5.0.zip |
34 |
| -``` |
35 |
| - |
36 |
| -### Security policy |
37 |
| - |
38 |
| -Elasticsearch ships with a pretty restrictive security policy. Plugins can specify the permissions |
39 |
| -that they need in `plugin-security.policy`. However, elasticsearch-analysis-voikko uses |
40 |
| -[JNA library](https://github.com/java-native-access/jna) which is already distributed with Elasticsearch |
41 |
| -and therefore can't be included in the plugin zip. This means that the security policy bundled with the |
42 |
| -plugin will not apply to JNA, yet it should be able to load `libvoikko` from the system. |
43 |
| - |
44 |
| -Therefore you need to create a custom security policy, granting Elasticsearch itself the permission |
45 |
| -to load `libvoikko`: |
46 |
| - |
47 |
| -``` |
48 |
| -grant { |
49 |
| - permission java.io.FilePermission "<<ALL FILES>>", "read"; |
50 |
| - permission java.lang.reflect.ReflectPermission "newProxyInPackage.org.puimula.libvoikko"; |
51 |
| -}; |
52 |
| -``` |
53 |
| - |
54 |
| -(You don't really need to grant read access to `<<ALL FILES>>`, you can pass the location |
55 |
| -of `libvoikko` instead.) |
56 |
| - |
57 |
| -Save this as `custom-elasticsearch.policy` and tell Elasticsearch to load it: |
58 |
| - |
59 |
| -``` |
60 |
| -export ES_JAVA_OPTS=-Djava.security.policy=file:/path/to/custom-elasticsearch.policy |
61 |
| -``` |
62 |
| - |
63 |
| -### Verify installation |
64 |
| - |
65 |
| -After installing the plugin, you can quickly verify that it works by executing: |
66 |
| - |
67 |
| -``` |
68 |
| -curl -XGET 'localhost:9200/_analyze' -d ' |
69 |
| -{ |
70 |
| - "tokenizer" : "finnish", |
71 |
| - "filter" : [{"type": "voikko", "libraryPath": "/directory/of/libvoikko", "dictionaryPath": "/directory/of/voikko/dictionaries"}], |
72 |
| - "text" : "Testataan voikon analyysiä tällä tavalla yksinkertaisesti." |
73 |
| -}' |
74 |
| -``` |
75 |
| - |
76 |
| -If this works without error messages, you can proceed to configure the plugin index. |
77 |
| - |
78 |
| -## Configuring |
79 |
| - |
80 |
| -Include `finnish` tokenizer and `voikko` filter in your analyzer, for example: |
81 |
| - |
82 |
| -```json |
83 |
| -{ |
84 |
| - "index": { |
85 |
| - "analysis": { |
86 |
| - "analyzer": { |
87 |
| - "default": { |
88 |
| - "tokenizer": "finnish", |
89 |
| - "filter": ["lowercase", "voikkoFilter"] |
90 |
| - } |
91 |
| - }, |
92 |
| - "filter": { |
93 |
| - "voikkoFilter": { |
94 |
| - "type": "voikko" |
95 |
| - } |
96 |
| - } |
97 |
| - } |
98 |
| - } |
99 |
| -} |
100 |
| -``` |
101 |
| - |
102 |
| -You can use the following filter options to customize the behaviour of the filter: |
103 |
| - |
104 |
| -| Parameter | Default value | Description | |
105 |
| -|-------------------|------------------|--------------------------------------------------| |
106 |
| -| language | fi_FI | Language to use | |
107 |
| -| dictionaryPath | system dependent | path to voikko dictionaries | |
108 |
| -| analyzeAll | false | Use all analysis possibilities or just the first | |
109 |
| -| minimumWordSize | 3 | minimum length of words to analyze | |
110 |
| -| maximumWordSize | 100 | maximum length of words to analyze | |
111 |
| -| libraryPath | system dependent | path to directory containing libvoikko | |
112 |
| -| poolMaxSize | 10 | maximum amount of Voikko-instances to pool | |
113 |
| -| analysisCacheSize | 1024 | number of analysis results to cache | |
114 |
| - |
115 |
| -## Development |
116 |
| - |
117 |
| -To run the tests, you need to specify `voikko.home` system property which should point to |
118 |
| -a directory containing libvoikko shared library and subdirectory `dicts` which contains |
119 |
| -the [morpho dictionary](http://www.puimula.org/htp/testing/voikko-snapshot/dict-morpho.zip). |
120 |
| - |
121 |
| -## License |
122 |
| - |
123 |
| -This library is released under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0). |
| 1 | +# Voikko Analysis for Elasticsearch |
| 2 | + |
| 3 | +The Voikko Analysis plugin provides Finnish language analysis using [Voikko](http://voikko.puimula.org/). |
| 4 | + |
| 5 | +## Supported versions |
| 6 | + |
| 7 | +| Plugin version | Elasticsearch version | |
| 8 | +| -------------- | ----------------------| |
| 9 | +| [0.6.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.6.0/README.md) | 7.3.2 | |
| 10 | +| [0.5.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.5.0/README.md) | 5.1.1 | |
| 11 | +| [0.4.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.4.0/README.md) | 2.2.1 | |
| 12 | +| [0.3.0](https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/blob/v0.3.0/README.md) | 1.5.2 | |
| 13 | + |
| 14 | +If you are not installing the latest version, follow the links in the table to see installation instructions for the old version. |
| 15 | + |
| 16 | +## Installing |
| 17 | + |
| 18 | +### Installing Voikko |
| 19 | + |
| 20 | +The plugin needs `libvoikko` shared library to work. Details of installing the library varies |
| 21 | +based on operating system. In Debian based systems `apt-get install libvoikko1` should work. |
| 22 | + |
| 23 | +Next, you'll need to download [morpho dictionary](http://www.puimula.org/htp/testing/voikko-snapshot/dict-morpho.zip) |
| 24 | +(for libvoikko version 4.0+, use [morpho dict v5](http://www.puimula.org/htp/testing/voikko-snapshot-v5/dict-morpho.zip) |
| 25 | +instead). |
| 26 | +Unzip this into Voikko's dictionary directory (e.g. `/usr/lib/voikko` in Debian) or into a directory you specify with |
| 27 | +`dictionaryPath` configuration property. |
| 28 | + |
| 29 | +### Installing the plugin |
| 30 | + |
| 31 | +Finally, to install the plugin, run: |
| 32 | + |
| 33 | +``` |
| 34 | +bin/elasticsearch-plugin install https://github.com/EvidentSolutions/elasticsearch-analysis-voikko/releases/download/v0.6.0/elasticsearch-analysis-voikko-0.6.0.zip |
| 35 | +``` |
| 36 | + |
| 37 | +### Security policy |
| 38 | + |
| 39 | +Elasticsearch ships with a pretty restrictive security policy. Plugins can specify the permissions |
| 40 | +that they need in `plugin-security.policy`. However, elasticsearch-analysis-voikko uses |
| 41 | +[JNA library](https://github.com/java-native-access/jna) which is already distributed with Elasticsearch |
| 42 | +and therefore can't be included in the plugin zip. This means that the security policy bundled with the |
| 43 | +plugin will not apply to JNA, yet it should be able to load `libvoikko` from the system. |
| 44 | + |
| 45 | +Therefore you need to create a custom security policy, granting Elasticsearch itself the permission |
| 46 | +to load `libvoikko`: |
| 47 | + |
| 48 | +``` |
| 49 | +grant { |
| 50 | + permission java.io.FilePermission "<<ALL FILES>>", "read"; |
| 51 | + permission java.lang.reflect.ReflectPermission "newProxyInPackage.org.puimula.libvoikko"; |
| 52 | +}; |
| 53 | +``` |
| 54 | + |
| 55 | +(You don't really need to grant read access to `<<ALL FILES>>`, you can pass the location |
| 56 | +of `libvoikko` instead.) |
| 57 | + |
| 58 | +Save this as `custom-elasticsearch.policy` and tell Elasticsearch to load it: |
| 59 | + |
| 60 | +``` |
| 61 | +export ES_JAVA_OPTS=-Djava.security.policy=file:/path/to/custom-elasticsearch.policy |
| 62 | +``` |
| 63 | + |
| 64 | +### Verify installation |
| 65 | + |
| 66 | +After installing the plugin, you can quickly verify that it works by executing: |
| 67 | + |
| 68 | +``` |
| 69 | +curl -XGET 'localhost:9200/_analyze' -d ' |
| 70 | +{ |
| 71 | + "tokenizer" : "finnish", |
| 72 | + "filter" : [{"type": "voikko", "libraryPath": "/directory/of/libvoikko", "dictionaryPath": "/directory/of/voikko/dictionaries"}], |
| 73 | + "text" : "Testataan voikon analyysiä tällä tavalla yksinkertaisesti." |
| 74 | +}' |
| 75 | +``` |
| 76 | + |
| 77 | +If this works without error messages, you can proceed to configure the plugin index. |
| 78 | + |
| 79 | +## Configuring |
| 80 | + |
| 81 | +Include `finnish` tokenizer and `voikko` filter in your analyzer, for example: |
| 82 | + |
| 83 | +```json |
| 84 | +{ |
| 85 | + "index": { |
| 86 | + "analysis": { |
| 87 | + "analyzer": { |
| 88 | + "default": { |
| 89 | + "tokenizer": "finnish", |
| 90 | + "filter": ["lowercase", "voikkoFilter"] |
| 91 | + } |
| 92 | + }, |
| 93 | + "filter": { |
| 94 | + "voikkoFilter": { |
| 95 | + "type": "voikko" |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +You can use the following filter options to customize the behaviour of the filter: |
| 104 | + |
| 105 | +| Parameter | Default value | Description | |
| 106 | +|-------------------|------------------|--------------------------------------------------| |
| 107 | +| language | fi_FI | Language to use | |
| 108 | +| dictionaryPath | system dependent | path to voikko dictionaries | |
| 109 | +| analyzeAll | false | Use all analysis possibilities or just the first | |
| 110 | +| minimumWordSize | 3 | minimum length of words to analyze | |
| 111 | +| maximumWordSize | 100 | maximum length of words to analyze | |
| 112 | +| libraryPath | system dependent | path to directory containing libvoikko | |
| 113 | +| poolMaxSize | 10 | maximum amount of Voikko-instances to pool | |
| 114 | +| analysisCacheSize | 1024 | number of analysis results to cache | |
| 115 | + |
| 116 | +## Development |
| 117 | + |
| 118 | +To run the tests, you need to specify `voikko.home` system property which should point to |
| 119 | +a directory containing libvoikko shared library and subdirectory `dicts` which contains |
| 120 | +the [morpho dictionary](http://www.puimula.org/htp/testing/voikko-snapshot/dict-morpho.zip). |
| 121 | + |
| 122 | +## License |
| 123 | + |
| 124 | +This library is released under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0). |
0 commit comments