본문 바로가기

programmer

(167)
[Elasticsearch] POI 영문 검색 개선 팁 영문 복합 명사 검색 시 특히 한국 사람들이 보통 띄어쓰기를 하지 않거나 & 기호를 잘 사용하지 않고 심지어는 검색어를 치다가 만다. 예를들면 다양한 경우의 수가 있는대 하기 표와 같이 사람들이 검색하는 '검색어'(POI)와 '의도'(검색 되길 원하는 결과)는 다음과 같다. 검색어 의도 cjenm cj enm ktg kt&g outbacksteak outbacksteakhouse fastfood fast food lotteworld lotte world, lotte world tower oneandonly, one&only one and only, one n only, one & only 이 외에도 많은 경우가 있겠지만 이를 해결할 방법을 찾아보자. 다행히 ELK 에서는 이를 처리하기 위한 다양한 필터나..
[파일명] dataFrame을 파일로 저장 시 파일 명 바꾸기 spark에서 아무리 파일 명을 설정해서 저장하고 싶어도 특정 패턴으로 파일 명이 생성 된다... 이때 파일명을 가지고 와서 rename 해주면 원하는 파일 명으로 바꿀 수 있다. import org.apache.hadoop.fs._ val hdfsUrl = "hdfs://nameservice1/user/zeppelin/data/myfolder/" val file_path = "part*" val new_fileName = "nevFile.csv" val fs = FileSystem.get(sc.hadoopConfiguration) val file = fs.globStatus(new Path(hdfsUrl + file_path))(0).getPath().getName() fs.rename(new Path..
[docker] docker localhost ip 확인하기 docker containner 안에서 localhost의 주소는 host PC에서 ifconfig로 쉽게 확인할 수 있다. 1. ifconfig 설치 $sudo apt install net-tools 2. ifconfig 실행 $ifconfig 3. containner 내부에서 curl 실행 확인 curl inetIP:9200
[Elasticsearch] 거리 가중치에 따른 Score 집계 방법 ELK에서 거리 가중치에 따라 score를 받고 싶을 때 사용한다. 하기 쿼리와 같이 "function_score"를 사용하면 거리 별 스코어를 받아 볼 수 있다.(linear 사용) GET your_index_name/_search { "query": { "function_score": { "functions": [ { "linear": {#decay 함수 명 "center": { #좌표 필드 명 "origin": [ 127.00493315155632, 37.57582519652989], "scale": "2km", "offset": "0km", "decay": 0.33 } } } ], "query": { "bool": { "must": [ { "dis_max": { "tie_breaker": 0, "..
Set up basic security for the Elastic Stack ES 기본 보안 설정방법은 아래 링크에 설명되어있다. 따라하다 보면 에러가 발생 할 수 있는대 이를 적어 놓는다... https://www.elastic.co/guide/en/elasticsearch/reference/7.15/security-basic-setup.html Set up basic security for the Elastic Stack | Elasticsearch Guide [7.15] | Elastic Elasticsearch monitors all files such as certificates, keys, keystores, or truststores that are configured as values of TLS-related node settings. If you update a..
python to elasticsearch 파이선에서 elk로 연결하고 bulk update 하는 방법을 알아보자. 기본적으로 ES가 잘 접속 되는지 확인한다. !pip install elasticsearch from elasticsearch import Elasticsearch from elasticsearch import helpers es_client = Elasticsearch("https://localhost:9200/", verify_certs=False) es_client.info() 데이터 null 처리와 날짜 형식 예외 처리 함수가 필요하다. from elasticsearch import Elasticsearch from elasticsearch import helpers from datetime import datetime de..
[Crawling] webdriver로 새로운 탭 열고 데이터 수집하기 가끔 크롤링 하다보면 테이블 행 a tag에 링크가 있고 그 링크 안의 데이터를 수집해서 다시 원본 탭으로 돌아오고 싶을 때가 있다. 그럴 때 쓰기 좋은 스크립트를 작성하였으니 참고 하고 입맛에 맏게 수정해서 쓰기 바란다. 새로운 탭 열고 func 수행 후 탭 닫고 복귀 from selenium import webdriver import time driver = webdriver.Chrome('./chromedriver.exe', options=options) driver.get('https://www.google.com/') def openNewTabNExecuteFunction(driver, tabIndex, url, func): # Open a new window driver.execute_scri..
[Elasticsearch] 영문 검색 시 띄어쓰기 제거[2/2] Elk에서 영문 검색 시 띄어쓰기를 하지 않고 연속되는 단어가 있는 경우 검색. kibana에서 실행 하면 된다. index 생성 setting, mapping 입력 tokenize를 사용해 ngram을 설정한다. 최소 2음절씩 최대 5음절로 토큰을 생성한다. PUT english_pattern_replace_test2 { "settings": { "analysis": { "char_filter": { "whitespace_remove": { "type": "pattern_replace", "pattern": "\\s+", "replacement": "" } }, "analyzer": { "custom_analyzer": { "type": "custom", "tokenizer": "my_customer_..
[Elasticsearch] 영문 검색 시 띄어쓰기 제거[1/2] Elk에서 영문 검색 시 띄어쓰기를 하지 않는경우 검색 방법을 알아보자. kibana에서 실행 하면 된다. index 생성 setting, mapping 입력 PUT english_pattern_replace_test { "settings": { "analysis": { "char_filter": { "whitespace_remove": { "type": "pattern_replace", "pattern": "\\s+", "replacement": "" } }, "analyzer": { "custom_analyzer": { "type": "custom", "tokenizer": "whitespace", "filter": ["lowercase", "asciifolding"], "char_filter": [..
Python DateTime 변환(날짜 양식 변환) Data 전처리하다 보면 날짜 양식이 모두 달라 처리하기 귀찮을 때가 있다. 이때 Datatime 라이브러리를 좀 활용하면 도움이 될까 하여 관련 함수를 공유한다. import locale import datetime import re def transDateTimeFromInputString(inputDate): result = "" datePatterns = { "koreanPattern" : r"(\d{4})년+(\d{1,2})월+(\d{1,2})일", "koreanPattern_with_space" : r"(\d{4})년\s+(\d{1,2})월\s+(\d{1,2})일", "slashPattern" : r"(\d{4})-+(\d{1,2})-+(\d{1,2})", "dotPattern" : r"(\d..

반응형