'Elastic/TheDefinitiveGuide'에 해당되는 글 33건

  1. 2015.12.03 [Elasticsearch - The Definitive Guide] Relevance is Broken!
  2. 2015.11.30 [Elasticsearch - The Definitive Guide] What is Relevance?
  3. 2015.11.30 [Elasticsearch - The Definitive Guide] Sorting tips.
  4. 2015.11.30 [Elasticsearch - The Definitive Guide] Validating Queries
  5. 2015.11.30 [Elasticsearch - The Definitive Guide] Mapping
  6. 2015.11.30 [Elasticsearch - The Definitive Guide] Deep Pagination
  7. 2015.11.30 [Elasticsearch - The Definitive Guide] bulk-format
  8. 2015.11.27 [Elasticsearch - The Definitive Guide] Optimistic Concurrency Control
  9. 2015.11.27 [Elasticsearch - The Definitive Guide] Creating a New Document
  10. 2015.11.27 [Elasticsearch - The Definitive Guide] Updating a Whole Document.

[Elasticsearch - The Definitive Guide] Relevance is Broken!

Elastic/TheDefinitiveGuide 2015. 12. 3. 17:04

동의 하지 않으시는 분들도 있습니다.

하지만 저는 서비스 특성과 요건에 따라 각자 선택할 몫이라고 생각 합니다.


원문링크)


원문 Snippet)

Don’t use dfs_query_then_fetch in production. It really isn’t required. Just having enough data will ensure that your term frequencies are well distributed. There is no reason to add this extra DFS step to every query that you run.


위 글을 가볍게 정리해 보면 이렇습니다.

분산 환경에서 하나의 index를 여러개의 shard로 쪼갰을 때 idf 값에 따라 relevancy 가 달라 질 수 있다는 이야기 입니다.

즉, local idf 값을 사용할 것인지 global idf 값을 사용할 것인지 search_type 이라는 파라미터를 통해서 결정 할 수 있다는 것입니다.


원문 snippet 은 보시면 아시겠지만 dfs 를 쓰지 말라고 하고 있습니다.

이것 역시 trade off 가 있기 때문에 판단은 사용하시는 분이 판단 하시면 됩니다.

relevance 또는 rank 처리에 있어서 custom 하게 하실 경우 크게 중요하지 않을 수도 있구요.

relevance 와 rank 작업이 중요 할 경우 dfs 를 사용해야 할 필요도 있습니다.


이런 것들도 similarity 기법을 뭘 사용할 것인지에 따라 달라 질 수 있기때문에 반드시라기 보다 경우에 따라 잘 사용하시면 좋겠습니다.


저는 개인적으로 그냥 dfs 빼고 사용해도 크게 무리는 없지 않나 생각 합니다.

Elasticsearch에서도 default search_type 은 query_then_fetch 로 적용 되어 있습니다.


dfs를 사용했을 때와 사용하지 않았을 때 검색 질의에 대한 성능적 차이가 있습니다.

다만, 규모가 작은 경우 별 차이는 없습니다. ㅡ.ㅡ;;

:

[Elasticsearch - The Definitive Guide] What is Relevance?

Elastic/TheDefinitiveGuide 2015. 11. 30. 17:10

relevance 에 대한 이야기를 하려고 기록 하는 것은 아닙니다.

다만 debugging 파라미터 중 주의 해서 사용 하셔야 하는 내용이 있어 공유 차원에서 기록해 봅니다.


[원문링크]


[원문 Snippet]

Producing the explain output is expensive. It is a debugging tool only. Don’t leave it turned on in production.


[Track score & explain]

- track score 의 경우 sorting 시 _score 이외 field 를 이용해서 sort 하고자 할 때 문서에 대한 relevance와 함께 조합을 원한다면 이 옵션을 true 로 켜야 합니다. 다만, 이 설정의 경우 연산 비용이 높기 때문에 필요한 경우가 아니라면 주의해서 사용을 하셔야 합니다.

- explain 옵션의 경우 _score 에 대한 계산 결과가 어떻게 해서 나오게 되었는지 자세한 explain 을 넘겨 주는 기능으로 역시 debugging 용으로만 사용을 하시고, 운영 환경에서는 off 로 설정해서 사용 하셔야 합니다.


즉, 둘다 시스템 자원 소모가 크기 때문에 사용에 주의 해서 사용 하라는 이야기 입니다.

:

[Elasticsearch - The Definitive Guide] Sorting tips.

Elastic/TheDefinitiveGuide 2015. 11. 30. 16:44

팁이라고 하기 좀 그렇지만 그냥 쉽게 놓칠수 있는 부분이 있어 기록 합니다.


[한 줄 요약]

- sorting 기능은 메모리를 많이 사용합니다.


[원문링크]


[원문 Snippet]

Sorting on a full-text analyzed field can use a lot of memory. See Fielddata for more information.

- FIelddata 는 보통 fielddata cache 기능을 이야기 합니다. 또한 circuit break 와 함께 참고 하셔야 합니다.


[팁]

- fields 사용 (전에는 multi fields 라고 불렀습니다.)

- analyzed field 에 대한 정렬은 메모리를 많이 사용하기 때문에 주의 해서 사용합니다.


:

[Elasticsearch - The Definitive Guide] Validating Queries

Elastic/TheDefinitiveGuide 2015. 11. 30. 16:23

사실 저도 많이 사용하지 않는 API이긴 합니다.

간혹 내부적으로 Query DSL 이 어떤식으로 Lucene Query로 해석 되는지 궁금할 때가 있는데요.

_validate query API를 이용하면 쉽게 번역이 가능 합니다.


아마도 query string 에 익숙하고 전문적으로 사용하시는 분들에게는 의미가 없을지도 모르겠지만 그럼에도 불구하고 유용한 API라고 생각합니다.


이유는 RDBMS 에서 Select 절 작성하고 나서 실행 전에 꼭 explain 떠 보시잖아요.

그런것과 같은 거라고 생각 하시면 되겠습니다.


[원문링크]


위 문서 보다는 references 문서가 좀 더 예제가 자세하니 링크 참고 하시면 되겠습니다.


[References]


:

[Elasticsearch - The Definitive Guide] Mapping

Elastic/TheDefinitiveGuide 2015. 11. 30. 15:26

간혹 dynamic mapping 기능으로 인한 type mismatch 오류를 경험 하시는 분들이 있습니다.

그래서 기록해 봤습니다.

The Definitive Guide 에 올라온 Note 입니다.


원문링크)


원문 Snippet)

This means that if you index a number in quotes ("123"), it will be mapped as type string, not type long. However, if the field is already mapped as type long, then Elasticsearch will try to convert the string into a long, and throw an exception if it can’t.


정리 및 작은 팁을 말씀 드리면,

- 정수형 이면 그냥 long 으로 선언 하세요.

- 실수 형이면 그냥 double 로 선언 하세요.

- ".." 로 묶으면 string 형으로 선언 됩니다.

- dynamic mapping 은 explicity 하게 사용하시는게 좋은 습관 입니다.


:

[Elasticsearch - The Definitive Guide] Deep Pagination

Elastic/TheDefinitiveGuide 2015. 11. 30. 11:55

기초적인 내용이지만 그냥 기록해 봅니다.


원문링크)

https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html


원문 Snippet)

[Deep Paging in Distributed Systems]

To understand why deep paging is problematic, let’s imagine that we are searching within a single index with five primary shards. When we request the first page of results (results 1 to 10), each shard produces its own top 10 results and returns them to the requesting node, which then sorts all 50 results in order to select the overall top 10.


Now imagine that we ask for page 1,000—results 10,001 to 10,010. Everything works in the same way except that each shard has to produce its top 10,010 results. The requesting node then sorts through all 50,050 results and discards 50,040 of them!


You can see that, in a distributed system, the cost of sorting results grows exponentially the deeper we page. There is a good reason that web search engines don’t return more than 1,000 results for any query.


요약하면,

- There is a good reason that web search engines don’t return more than 1,000 results for any query.

- 불필요한 자원 및 연산에 대한 낭비로 문제가 될 수 있다.


이런 문제를 해결 하기 위해서는 cache 솔루션과 잘 조합해서 사용하시면 그나마 문제를 해결 하실수는 있습니다.

그럼에도 불구하고 근본적인 해결책은 아닙니다.

:

[Elasticsearch - The Definitive Guide] bulk-format

Elastic/TheDefinitiveGuide 2015. 11. 30. 11:43

Elasticsearch에서 bulk request 시 사용하는 format 에 대한 이야기 입니다.

이 이야기를 기록하는 이유는 elasticsearch 내부에서 동작하는 원리를 쉽게 이해 할 수 있기 때문 입니다.


원문링크)

https://www.elastic.co/guide/en/elasticsearch/guide/current/distrib-multi-doc.html#bulk-format


[Why the funny format?]

  • Parse the JSON into an array (including the document data, which can be very large)
  • Look at each request to determine which shard it should go to
  • Create an array of requests for each shard
  • Serialize these arrays into the internal transport format
  • Send the requests to each shard


정리하자면,

bulk request 를 받아서 다시 풀고 적절한 node의 shard 로 forward 되도록 생성한 후 send or request 한다 입니다.

:

[Elasticsearch - The Definitive Guide] Optimistic Concurrency Control

Elastic/TheDefinitiveGuide 2015. 11. 27. 15:35
Conflict 에 대한 내용입니다.

역시 잊어버릴 까봐 기록해 봅니다.


원문링크) 


내용요약)

- 내부적으로 같은 문서에 대한 수정이 발생 할 경우 version 정보는 계속 증가 합니다.

- 이미 갱신된 문서에 대해서 이전 version 정보를 가지고 수정 요청이 들어 오게 될 경우 conflict 오류를 발생 시킵니다.

- 원본 데이터에 대한 version 정보를 이미 사용중이라면 version_type=external 로 설정해서 사용 할 수 있습니다.


transaction 처리가 필요한 데이터에 대해서는 사용하시면 좋을 것 같습니다.


:

[Elasticsearch - The Definitive Guide] Creating a New Document

Elastic/TheDefinitiveGuide 2015. 11. 27. 15:15

색인 시 유용하게 활용 가능한 방법이라 기록해 봅니다.


원문링크)


색인 요청 시 unique 하게 한번만 생성되도록 해주는 API 입니다.

REST API로 요청 시 op_type=create 또는 _create 로 요청 하시면 됩니다.


각 비즈니스 요구사항에 따라 다르겠지만 유용하게 활용 할 수 있을것 같습니다.

:

[Elasticsearch - The Definitive Guide] Updating a Whole Document.

Elastic/TheDefinitiveGuide 2015. 11. 27. 15:07

아주 기본적인 내용이라 그냥 보고 넘어 갈까 했지만, 누군가에게는 필요한 정보 일수도 있어서 기록해 봅니다.


원문링크)


Content Snippet)

Documents in Elasticsearch are immutable; we cannot change them. Instead, if we need to update an existing document, we reindex or replace it, which we can do using the same index API that we have already discussed in Indexing a Document.


종종 elasticsearch 사용하시는 분들중에 update 에 대해서 문의를 합니다.

또는 mapping 정보 변경 시, field 수정/추가 시 등등..


immutable 즉, 불변이라는 것이죠.

수정이 안됩니다. 그렇기 때문에 reindex or replace 라고 하는 것입니다.

동일 문서 ID 로 색인 요청을 하게 되면 delete -> insert 로 동작 합니다.


사용하면서 참고 하시면 좋겠습니다.

: