티스토리 뷰

Elasticsearch에서는 서버 부하를 줄이기 위하여, 기본적으로 10000개의 응답이 회신된다.

이는 인덱스 설정을 바꿔주면 해결이 된다.

 

from elasticsearch import Elasticsearch

es = Elasticsearch(hosts=['http://localhost:9200'])

es.indices.put_settings(
 index="my_index",     # 이 필드는 꼭 없어도 되는 것 같음.
 body= {"index" : {
            "max_result_window" : 500000
          }})

resp = es.search(index="my_index", query={"match_all": {}}, size=500000)
print("Got %d Hits:" % resp['hits']['total']['value'])

curl 명령어로도 가능하다.

curl -XPUT http://localhost:9200/my_index/_settings -H "Content-Type: application/json" -d "{\"index\": {\"max_result_window\": 500000}}"

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함