'inverted'에 해당되는 글 2건

  1. 2017.11.14 [Lucene] Inverted index file - 역인덱스 파일
  2. 2015.12.09 [Elasticsearch - The Definitive Guide] Dynamically Updatable Indices

[Lucene] Inverted index file - 역인덱스 파일

ITWeb/검색일반 2017. 11. 14. 23:15

루씬에서 검색을 하기 위해 필요한 파일을 살짝 알아보겠습니다.

파일 구조와 목록은 아래 문서를 참고 하시기 바랍니다.

Lucene Index File Formats)

https://lucene.apache.org/core/7_1_0/core/org/apache/lucene/codecs/lucene70/package-summary.html#package.description


그럼 실제 검색을 위해 보셔야 하는 기본이 되는 클래스는 

  • IndexSearcher
  • IndexReader
  • CollectionStatistics
  • TermStatistics

이렇게 4개 정도 보시면 될 것 같습니다.


검색을 위해 필요한 정보는

  • Documents
  • Fields
  • Terms
  • FieldInvertState

이렇게 4개 정도가 필요 합니다.

딱 봐도 "searchField:elasticsearch" 하면 

  • searchField 라는 field 정보가 필요하고, 
  • elasticsearch 라는 term 관련 정보도 필요하고, 
  • elasticsearch 라는 term 이 있는 document 정보도 필요하고,
  • 해당 field 에서의 term 이 추출 된 offset과 position 정보가

필요합니다.


이걸 정리한 이유는 오늘 누가 custom function score query 를 사용하여 다수의 field 에 대한 ranking term boosting 기능을 사용하고 있는데 성능적으로 개선 할 수 있는 방법이 없는지 물어봐서 간단하게 정리해봤습니다.

Query 튜닝은 한계가 반드시 존재 합니다.

서버의 구조적인 개선과 튜닝을 병행해야 하며 다수의 field 에 대한 다수의 term boosting 은 최적화를 통해 최소화 해서 사용하는걸 추천 드립니다.

그리고 inverted index file 이라는 것은 루씬에서 하나의 파일만 이야기 하는 것이 아니라 lucene 이 가지고 있는 index file 목록들이 inverted index file 을 구성 한다고 보시면 될 것 같습니다.

:

[Elasticsearch - The Definitive Guide] Dynamically Updatable Indices

Elastic/TheDefinitiveGuide 2015. 12. 9. 16:25

Elasticsearch가 lucene 기반으로 만들어진 분산검색엔진 이라는 것은 이미 잘 알고 계실겁니다.

하지만 elasticsearch를 사용하시는 분들중 lucene을 잘 아시는 분들은 그렇게 많이 계시지는 않은것 같아 참고 할 만한 좋은 내용이 있어 올려 봅니다.


원문링크)

https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-indices.html


원문 Snippet)

[Deletes and Updates]

Segments are immutable, so documents cannot be removed from older segments, nor can older segments be updated to reflect a newer version of a document. Instead, every commit point includes a .del file that lists which documents in which segments have been deleted.

When a document is “deleted,” it is actually just marked as deleted in the .del file. A document that has been marked as deleted can still match a query, but it is removed from the results list before the final query results are returned.

Document updates work in a similar way: when a document is updated, the old version of the document is marked as deleted, and the new version of the document is indexed in a new segment. Perhaps both versions of the document will match a query, but the older deleted version is removed before the query results are returned.


아래는 원문에 나와 있는 per-segment search works 간단 정리 입니다.

1) write in-memory buffer

2) write new segment file from in-memory buffer

3) write commit point (Refresh API on Elasticsearch)

4) flush in-memory buffer

5) searchable


※ 이 내용과 실제 elasticsearch 에서 primary shard 와 replica shard 간 데이터가 sync 되는 것과는 다른 내용입니다.

: