Java port of the pymorphy2
Clone project:
git clone https://github.com/anti-social/jmorphy2
cd jmorphy2
Compile project, build jars and run tests:
Build with vagga (no java and gradle needed):
vagga build
Same with gradle (minimum gradle version is 4.3
):
gradle build
To see all available vagga commands just type vagga
Default elasticsearch version against which plugin is built is 6.3.2
To build for specific elastisearch version run build as:
vagga assemble -PesVersion=6.2.3
Or:
gradle assemble -PesVersion=6.2.3
Supported elasticsearch versions: 6.0.x
, 6.1.x
, 6.2.x
, 6.3.x
For older elasticsearch version use specific branches:
es-5.4
for Elasticsearch5.4.x
,5.5.x
and5.6.x
es-5.1
for Elasticsearch5.1.x
,5.2.x
and5.3.x
Install plugin:
# Specify correct path of your Elasticsearch installation
export es_home=/opt/elasticsearch
sudo ${es_home}/bin/elasticsearch-plugin install file:jmorphy2-elasticsearch/build/distributions/analysis-jmorphy2-0.2.0-SNAPSHOT-es-6.2.3zip
Or just run elasticsearch inside the container (only works for plugin built for default Elasticsearch version):
# build container and run elasticsearch with jmorphy2 plugin
vagga elastic
Create index with specific analyzer and test it:
curl -X PUT -H 'Content-Type: application/yaml' 'localhost:9200/test_index' -d '---
settings:
index:
analysis:
filter:
delimiter:
type: word_delimiter
preserve_original: true
jmorphy2_russian:
type: jmorphy2_stemmer
name: ru
jmorphy2_ukrainian:
type: jmorphy2_stemmer
name: uk
analyzer:
text_ru:
tokenizer: whitespace
filter:
- delimiter
- lowercase
- jmorphy2_russian
text_uk:
tokenizer: whitespace
filter:
- delimiter
- lowercase
- jmorphy2_ukrainian
'
# Test russian analyzer
curl -X GET -H 'Content-Type: application/yaml' 'localhost:9200/test_index/_analyze' -d '---
analyzer: text_ru
text: Привет, лошарики!
'
curl -X GET -H 'Content-Type: application/yaml' 'localhost:9200/test_index/_analyze' -d '---
analyzer: text_ru
text: ёж еж ежики
'
# Test ukrainian analyzer
curl -X GET -H 'Content-Type: application/yaml' 'localhost:9200/test_index/_analyze' -d '---
analyzer: text_uk
text: Пригоди Котигорошка
'
curl -X GET -H 'Content-Type: application/yaml' 'localhost:9200/test_index/_analyze' -d '---
analyzer: text_uk
text: їжаки
'
curl -X GET -H 'Content-Type: application/yaml' 'localhost:9200/test_index/_analyze' -d $'---
analyzer: text_uk
text: комп\'ютером
'