'Optimizing'에 해당되는 글 1건

  1. 2014.01.23 [elasticsearch] query optimizing....

[elasticsearch] query optimizing....

Elastic/Elasticsearch 2014. 1. 23. 15:23

원문 : https://speakerdeck.com/elasticsearch/query-optimization-go-more-faster-better


filters are fast, cached, composable, short-circuit
    no score is calculated, only inclusion / exclusion

term, terms, range query 에 대해 term, terms, range filter 로 대체 하여 사용.


[from]

{
    "query" : {
        "term" : {
            "field" : "value"
        }
    }
}


[to]



{
    "query" : {
        "filtered" : {
            "query" : {
                "match_all" : {}
            },
            "filter" : {
                "term" : {
                    "field" : "value"
                }
            }
        }
    }
}



Top level filter is slow.


{
    "query" : { … },
    "filter" : { … }
}


Don't use this unless you need it
(only useful with facets)



Using Count (더 빠름)


[from]

/{index}/_search
{
    "query" : { … },
    "size" : 0
}


[to]


/{index}/_search?search_type=count
{
    "query" : { … }
}


Rescore API


1. Query/filter to quickly find top N results
2. Rescore with complex logic to find top 10


Do not EVER use these in a search script.


[to]

_source.field

_fields.field

두개 항목은 disk 에서 읽기 때문에 느립니다.


[from]

doc[field]

in-memory field data 를 읽기 때문에 빠릅니다.







: