Skip to content

Commit

Permalink
Merge branch 'release/7.9.3_AdoptOpenJDK11'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuflatland-lf committed May 25, 2021
2 parents ae153ce + 9102df0 commit e82fb8d
Show file tree
Hide file tree
Showing 6 changed files with 965 additions and 42 deletions.
82 changes: 45 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
# elasticsearch-docker-composer-for-liferay-7
This is for setting up docker-composer to test Elasticsearch and Kuromoji against Liferay 7 GA6 / DXP de42 (Elasticsearch 6.1.3). **The JDK type (OpenJDK / OracleJDK) need to match between Elasticsearch and Liferay because Liferay using binary protocol to communicate with Elasticsearch. Master is ```Oracle jdk8``` version. If you are looking for ```${elasticsearch_version}_openjdk8``` version, please refer ```${elasticsearch_version}_openjdk8``` branch of this repository.**

If you are using lower than Liferay 7 GA6 / DXP de42, please use branch ```2.4_openjdk8``` or ```2.4_oraclejdk8``` depending on what version of JDK type (OpenJDK / OracleJDK) using for Liferay.
This is for setting up docker-composer to test Elasticsearch and Kuromoji against Liferay 7.3 GA1 / DXP 7.3 SP1 (Elasticsearch 7.9.3).

## Required environment
- Docker 17.06.2-ce >=
- Java8 (Oracle JDK 8 or Open JDK 8)

## How to set up (Oracle JDK, master branch)
1. Clone this repository
2. Change the file permission of ```/es/docker-entrypoint.sh``` to executable.
3. Go back to the root folder and run ```docker-compose up --build``` or just ```docker-compose up```
4. Start Liferay DXP / 7
5. Login as an administrator and navigate to Control Panel -> Configuration -> System Setting -> Basic configuration tab -> Elasticsearch
6. Change Operation mode to REMOTE and Transport addresses to your IP according to the console log, '''publish_address {127.0.0.1:9300}'''. In this case, the Transport address should be ```"127.0.0.1:9300"```
7. Click save and restart Liferay server
8. Loging as an administrator, navigate to Control Panel -> Configuration -> Server Configuration and run reindex.

## How to set up (Open JDK, openjdk8 branch)
- Docker 3.3.3 >=
- Java8 or Java11

## How to set up

1. Clone this repository
2. Go back to the root folder and run ```docker-compose up --build``` or just ```docker-compose up```
3. Start Liferay DXP / 7
4. Login as an administrator and navigate to Control Panel -> Configuration -> System Setting -> Basic configuration tab -> Elasticsearch
5. Change Operation mode to REMOTE and Transport addresses to your IP according to the console log, '''publish_address {127.0.0.1:9300}'''. In this case, the Transport address should be ```"127.0.0.1:9300"```
6. Click save and restart Liferay server
7. Loging as an administrator, navigate to Control Panel -> Configuration -> Server Configuration and run reindex.

## Modify user dictionaly
1. Change the file permission of `/es/docker-entrypoint.sh` to executable.
1. Go back to the root folder and run `docker-compose up --build` or just `docker-compose up`
1. Start Liferay 7.3
1. Login as an administrator and navigate to Control Panel -> Configuration -> System Setting -> Search -> Elasticsearch 7
1. Check `Production Mode Enabled` true.
1. Open `index-settings.json` and paste it into `Additional Index Configurations` Text field.
1. Open `liferay-type-mappings.json` and paste it into `Override Type Mappings` Text field.
1. Click save and restart Liferay server
1. Loging as an administrator, navigate to Control Panel -> Configuration -> Server Configuration and run reindex.

## Modify user dictionary

1. Open /es/config/userdict_ja.txt
2. Modify contents according to the [user guide](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-kuromoji-tokenizer.html)

## Initialize set up after change configurations
1. Stop services with ```docker-compose stop```
2. Delete folders under ```/es/data```
3. Run ```docker rm -f `docker ps -qa` ```
4. Run ```docker rmi `docker images | sed -ne '2,$p' -e 's/ */ /g' | awk '{print $1":"$2}'` ```
5. If 4 doesn't work, try ```docker rmi $(docker images | awk '/^<none>/ { print $3 }') ```

1. Stop services with `docker-compose stop`
2. Delete folders under `/es/data`
3. Run `` docker rm -f `docker ps -qa` ``
4. Run `` docker rmi `docker images | sed -ne '2,$p' -e 's/ */ /g' | awk '{print $1":"$2}'` ``
5. If 4 doesn't work, try `docker rmi $(docker images | awk '/^<none>/ { print $3 }') `

## Log files
under ```/es/logs```

under `/es/logs`

## Data files
under ```/es/data```

under `/es/data`

## How to investigate query of Liferay

Enable slow query log with low threshold would be the easiest way.
1. Navigate to Sense ```http://localhost:5601/app/sense``` e.g.
2. Modify query below appropriately.

1. Navigate to Sense `http://localhost:5601/app/dev_tools#/console` e.g.
1. Find index names at `http://localhost:5601/app/management/data/index_management/indices`.
1. Modify query below appropriately.

```javascript
PUT /[index_name]/_settings
Expand All @@ -66,12 +68,15 @@ PUT /[index_name]/_settings
"index.indexing.slowlog.source": "1000"
}
```

3. Search / index and you'll see log files under ./es/logs
you can also change ./es/config/elasticsearch.yml for above settings and run ```docker-compose up --build```
you can also change ./es/config/elasticsearch.yml for above settings and run `docker-compose up --build`

## Search from query to see how analyzer works.
1. Navigate to ```http://localhost:5601/app/sense``` and select server (http://elasticsearch:9200)
2. Paste query below

1. Navigate to `http://localhost:5601/app/dev_tools#/console`
1. Paste query below

```
GET /[index_name]/_analyze
{
Expand All @@ -81,8 +86,11 @@ GET /[index_name]/_analyze
```

## How to access elasticsearch and tools

### Elasticsearch
```http://localhost:9200```

`http://localhost:9200`

### Kibana (Analyzing tool for Elasticsearch)
```http://localhost:5601```

`http://localhost:5601`
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.1"
version: "3.8"
services:
elasticsearch:
build: es
Expand All @@ -17,7 +17,8 @@ services:
- ./es/config/userdict_ja.txt:/usr/share/elasticsearch/config/userdict_ja.txt
- ./es/logs/:/var/log/elasticsearch/
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
- discovery.type=single-node
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- xpack.graph.enabled=false
Expand All @@ -26,8 +27,9 @@ services:
- xpack.watcher.enabled=false

kibana:
image: docker.elastic.co/kibana/kibana:6.1.4
image: docker.elastic.co/kibana/kibana:7.9.3
ports:
- "5601:5601"
environment:
- xpack.security.enabled=false
- "ELASTICSEARCH_HOSTS=http://elasticsearch:9200"
6 changes: 4 additions & 2 deletions es/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM docker.elastic.co/elasticsearch/elasticsearch:6.1.3
FROM docker.elastic.co/elasticsearch/elasticsearch:7.9.3

RUN elasticsearch-plugin install analysis-kuromoji
COPY ./elasticsearch-analysis-kuromoji-ipadic-neologd-7.9.3-SNAPSHOT.zip ./

RUN elasticsearch-plugin install file:./elasticsearch-analysis-kuromoji-ipadic-neologd-7.9.3-SNAPSHOT.zip
RUN elasticsearch-plugin install analysis-icu
RUN elasticsearch-plugin install analysis-smartcn
RUN elasticsearch-plugin install analysis-stempel
Binary file not shown.
35 changes: 35 additions & 0 deletions index-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"analysis": {
"filter" : {
"liferay_readingform" : {
"type": "kuromoji_ipadic_neologd_readingform",
"use_romaji": "false"
}
},
"analyzer": {
"liferay_kuromoji": {
"type": "custom",
"tokenizer": "liferay_kuromoji_tokenizer",
"char_filter": [
"html_strip",
"kuromoji_ipadic_neologd_iteration_mark"
],
"filter" : [
"lowercase",
"cjk_width",
"kuromoji_ipadic_neologd_baseform",
"kuromoji_ipadic_neologd_part_of_speech",
"kuromoji_ipadic_neologd_readingform",
"kuromoji_ipadic_neologd_stemmer"
]
}
},
"tokenizer": {
"liferay_kuromoji_tokenizer": {
"type": "kuromoji_ipadic_neologd_tokenizer",
"mode": "search",
"user_dictionary": "userdict_ja.txt"
}
}
}
}
Loading

0 comments on commit e82fb8d

Please sign in to comment.