Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyza committed Dec 6, 2024
1 parent 1411478 commit 2495f3a
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
elasticsearch 7.17.18
java openjdk-17.0.2
maven 3.9.0
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG ES_VERSION=8.6.2
FROM docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION}

ARG ES_VERSION
COPY --chown=elasticsearch:elasticsearch ./target/releases/elasticsearch-analysis-lemmagen-${ES_VERSION}-plugin.zip /tmp/elasticsearch-analysis-lemmagen-${ES_VERSION}-plugin.zip

USER elasticsearch

RUN elasticsearch-plugin install file:///tmp/elasticsearch-analysis-lemmagen-${ES_VERSION}-plugin.zip

RUN mkdir -p /usr/share/elasticsearch/config/lemmagen && \
cd /usr/share/elasticsearch/config/lemmagen && \
curl -L https://github.com/vhyza/lemmagen-lexicons/raw/master/free/lexicons/en.lem -o en.lem
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
elasticsearch:
# image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
build:
context: .
platforms:
- linux/amd64
args:
- ES_VERSION=8.6.2
ports:
- 9200:9200
environment:
- cluster.name=lemmagen-test
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- xpack.security.http.ssl.enabled=false
- xpack.security.transport.ssl.enabled=false
- network.host=0.0.0.0
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
4 changes: 2 additions & 2 deletions plugin-descriptor.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description=Lemmatizer token filter
version=${elasticsearch.version}
version=${project.version}
name=elasticsearch-analysis-lemmagen
classname=org.elasticsearch.plugin.analysis.lemmagen.AnalysisLemmagenPlugin
java.version=1.8
elasticsearch.version=${plugin.version}
elasticsearch.version=${elasticsearch.version}
19 changes: 6 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-analysis-lemmagen</artifactId>
<version>8.6.1</version>
<version>8.6.2</version>
<packaging>jar</packaging>
<properties>
<plugin.version>8.6.1</plugin.version>
<lucene.version>9.4.2</lucene.version>
<elasticsearch.version>8.6.1</elasticsearch.version>
<elasticsearch.version>8.6.2</elasticsearch.version>
<plugin.version>${elasticsearch.version}</plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
Expand All @@ -37,12 +36,6 @@
<artifactId>slf4j-simple</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${lucene.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
Expand Down Expand Up @@ -86,13 +79,13 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>[2.16.0,)</version>
<version>2.23.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>[2.16.0,)</version>
<version>2.23.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -133,7 +126,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<version>3.2.2</version>
<configuration>
<!-- disable security manager for tests -->
<argLine>-Dtests.security.manager=false</argLine>
Expand Down
75 changes: 75 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

set -e

# To clear possible old index
curl -s -H "Content-Type: application/json" -X DELETE "http://localhost:9200/lemmagen-test" > /dev/null

echo -e "--------------- CREATE INDEX ---------------\n"
curl -f -H "Content-Type: application/json" -X PUT "http://localhost:9200/lemmagen-test" -d '{
"settings": {
"index": {
"analysis": {
"filter": {
"lemmagen_filter_en": {
"type": "lemmagen",
"lexicon": "en"
}
},
"analyzer": {
"lemmagen_en": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": [
"lemmagen_filter_en"
]
}
}
}
}
},
"mappings": {
"properties": {
"text": {
"type": "text",
"analyzer": "lemmagen_en"
}
}
}
}'

echo -e "\n"
echo -e "--------------- ANALYZE TEXT ---------------\n"
curl -f -H "Content-Type: application/json" -X GET "http://localhost:9200/lemmagen-test/_analyze" -d '
{
"text": "I am late.",
"analyzer": "lemmagen_en"
}'

echo -e "\n"
echo -e "--------------- INDEX DOCUMENT ---------------\n"
curl -f -H "Content-Type: application/json" -X PUT "http://localhost:9200/lemmagen-test/_doc/1?refresh=wait_for" -d '
{
"user": "tester",
"published_at": "2013-11-15T14:12:12",
"text": "I am late."
}'


echo -e "\n"
echo -e "--------------- SEARCH DOCUMENT ---------------\n"
curl -f -H "Content-Type: application/json" -X GET "http://localhost:9200/lemmagen-test/_search" -d '
{
"query": {
"match": {
"text": "is"
}
}
}'

echo -e "\n"
echo -e "--------------- DELETE INDEX ---------------\n"
curl -f -H "Content-Type: application/json" -X DELETE "http://localhost:9200/lemmagen-test"

echo -e "\n"
echo -e "👍 ALL DONE 👍\n"

0 comments on commit 2495f3a

Please sign in to comment.