개인 스터디 자료임.
1. es.zip 파일을 압축을 푼다.
2. dockerdata 디렉토리로 압축을 푼 디렉토리를 복사
3. es 디렉토리로 들어가서 다음 명령 실행
es$ docker compose up -d
참고) DB 포트 변경안해도 됨. docker-compose.yaml 파일에 보면 외부 포트를 9906 으로 해놓음.
4. 테스트. 8000 번 포트로 접속해 보면 됨.
http://localhost:8000/
5. 실습용 라이브러리 설치
es$ sudo apt-get update
es$ sudo apt install python3-pip
es$ sudo pip3 install mysql-connector
es$ sudo pip3 install requests
6.EL 에서 products 라는 인덱스를 만들기. get 방식으로 접속하면 됨
6.1 조회?
http://localhost:9200/products
6.2 인덱스 지우기
es/ingestor$ pyton3 tools/delete_index.py
6.3 인덱스 생성
es/ingestor$ python3 create_index1.py
{"acknowledged":true,"shards_acknowledged":true,"index":"products"}
6.4 인덱스 확인
es/ingestor$ python3 tools/check_es_index.py
{"took":22,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":0,"relation":"eq"},"max_score":null,"hits":[]}}
6.5 스키마 확인
es/ingestor$ python3 tools/get_es_schema.py
{"products":{"aliases":{},"mappings":{"properties":{"content":{"type":"text"},"id":{"type":"long"},"image_file":{"type":"text"},"modified_date":{"type":"date"},"post_date":{"type":"date"},"shipped_from":{"type":"text"},"title":{"type":"text"},"url":{"type":"text"}}},"settings":{"index":{"routing":{"allocation":{"include":{"_tier_preference":"data_content"}}},"number_of_shards":"1","provided_name":"products","creation_date":"1661837676190","analysis":{"analyzer":{"analyzer-name":{"filter":"lowercase","type":"custom","tokenizer":"keyword"}}},"number_of_replicas":"1","uuid":"PTx4eVgiQYaRRIPCW4q7Vw","version":{"created":"7130299"}}}}}
mhchae3@AyaanFelix:/mnt/d/dockerdata/es/ingestor$
7. 워드 프레스 로그인
http://localhost:8000/wp-login.php
7.1 관리자 페이지
http://localhost:8000/wp-admin/
상품 -> 모든 상품
8. ES에 ingestion 하기
es/ingestor$ python3 ingestor1.py
9. 확인하기
es/ingestor$ python3 tools/check_es_index.py
{"took":965,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":7,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"products","_type":"_doc","_id":"90063200dc4ce5dc4271f7bb1b9750e481a5c8f6","_score":1.0,"_source":{
"content": "\ub300\ud615 \ud654\ubd84\uc785\ub2c8\ub2e4. \uc0ac\uc774\uc988\ub294 13\" \uc785\ub2c8\ub2e4.",
"id": 10,
"image_file": "2021/07/terra-cotta-planter.jpg",
"modified_date": "2021-07-02T15:28:15",
"post_date": "2021-07-01T18:55:54",
"shipped_from": "\ud574\uc678",
"title": "\ub300\ud615 \ud14c\ub77c\ucf54\ud0c0 \ud654\ubd84",
10. 웹에서 확인
http://localhost:9200/products/_search?q=검색어
위에 검색어에 내가 찾는 것을 넣으면 됨.
11. wordpress와 연동하기
http://localhost:8000/search.php?s=검색어
'Infra > 검색엔진' 카테고리의 다른 글
kibana 설치하기 (8.7.0) (0) | 2023.08.30 |
---|---|
Elasticsearch 도커 설치 (0) | 2023.08.30 |
Knowledge Graph (0) | 2022.08.30 |
Solr 설치 (0) | 2021.07.01 |
Solr 관련 블로그 (0) | 2021.06.30 |
댓글