대머리개발자

[solr9] 색인.. 본문

개발이야기/오픈소스 설치

[solr9] 색인..

대머리개발자 2024. 2. 27. 15:04
728x90

7만건 정도 테스트로 색인 해봤는데.. 

 

    final val urlString = "http://localhost:8983/solr/whyContent"
    // async, non-blocking
    val solrClient: Http2SolrClient = Http2SolrClient.Builder(urlString).build()

    fun testBatchJob(){
      siContentService.searchAll().doOnNext { addAndCommit(it, SolrInputDocument()) }.subscribe()
    }

    fun addAndCommit(siContent: SiContent,  doc: SolrInputDocument){
        doc.addField("id", siContent.uid)
        doc.addField("name", siContent.title)
        doc.addField("content", removeHtmlWithJsoup(siContent.content))
        solrClient.add(doc)
        solrClient.commit()
        println("Documents added")
    }

    fun removeHtmlWithJsoup(input: String): String {
        return Jsoup.parse(input).text()
    }

 

DataImportHandler를 이용해 DB 직접 조지면 더 빠를듯..

 

DB검색보다 전문검색을 하는 이유는!!

1. 속도

 

본문내용이 많다 보니  27초 ㅋㅋ

이미 여기서 게임SET

 

2. 형태소 분석

DB검색은 정확하게 "운동화"만 검색하지만

전문검색은 "운동+화"에 대한 형태소로 좀 더 많은 내용을 검색해 준다.

 

3. 동의어 검색

필요한 내용을 관리자가 직접 만들어야 되지만 파워풀한 기능이다.

동의어로 엮어 놓으면 ["운동화", "슈즈", "신발", ...] 다 함께 검색이 된다.

 

 

정리!

와이즈넛이나 다이퀘스트, 솔트룩스, 코난 등등 상용제품으로 연동도 해봤지만

오픈소스 위에 껍데기 포장해서 파는것이 아닌가 싶다(뇌피셜)

 

연구좀 더 해봐야겠지만 간단하게 구축하고 테스트하기 너무 좋다.

 

https://solr.apache.org/guide/solr/latest/deployment-guide/solrj.html

 

SolrJ :: Apache Solr Reference Guide

SolrJ allows more than just querying and indexing. It supports all of Solr’s APIs. Accessing Solr’s other APIs is as easy as finding the appropriate request object, providing any necessary parameters, and passing it to the request() method of your Solr

solr.apache.org

 

728x90

'개발이야기 > 오픈소스 설치' 카테고리의 다른 글

[solr9] - 동의어 검색  (0) 2024.02.29
[solr9] - core 생성  (0) 2024.02.29
[solr9] dev 설치  (1) 2024.02.23
K8S - 노드 이전!  (0) 2024.02.22
그라파나 + Loki Retention 설정  (0) 2024.02.14