{"id":1080,"date":"2020-07-02T23:37:50","date_gmt":"2020-07-02T14:37:50","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=1080"},"modified":"2020-07-05T08:29:58","modified_gmt":"2020-07-04T23:29:58","slug":"elasticsearch-deep-paging-%eb%ac%b8%ec%a0%9c","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=1080","title":{"rendered":"Elasticsearch deep paging \ubb38\uc81c"},"content":{"rendered":"<h1>Elasticsearch deep paging \ubb38\uc81c<\/h1>\n<h2>\ubb38\uc81c\uc810<\/h2>\n<p>\ud398\uc774\uc9c0 \uc0ac\uc774\uc988\uac00 100 \uc774\uace0, 30 \ud398\uc774\uc9c0\ub97c \uac80\uc0c9\ud558\ub824\uace0 \ud558\uba74, 3000 \uac1c\uc758 \ubb38\uc11c\ub97c \uc815\ub82c\ud574\uc57c \ud558\uace0 \uadf8 \ub2e4\uc74c\uc5d0 \ub9c8\uc9c0\ub9c9 100 \uac1c\uc758 \ubb38\uc11c\ub97c \ubc18\ud658\ud558\uac8c \ub429\ub2c8\ub2e4.<\/p>\n<p>\uc774 \ubb38\uc81c\ub294 \ub354 \uae4a\uc774 50 \ud398\uc774\uc9c0 200 \ud398\uc774\uc9c0\ub85c \ub4e4\uc5b4\uac08 \uc218\ub85d \ub354 \ub9ce\uc740 \uba54\ubaa8\ub9ac\ub97c \uc0ac\uc6a9\ud574\uc57c \ud558\uace0 \uacb0\uad6d\uc740 Elasticsearch \uac00 \uc8fd\ub294 \uacb0\uacfc\ub97c \uac00\uc838\uc635\ub2c8\ub2e4.<\/p>\n<p>\uc778\ub371\uc2a4\uac00 \uc5ec\ub7ec \uac1c\ub85c \ub098\ub258\uc5b4 \uc788\ub294 \uacbd\uc6b0, \uac01 \uc0e4\ub4dc\ubcc4\ub85c <code>200 \ud398\uc774\uc9c0 * 100 \uac1c \ubb38\uc11c<\/code> \ub97c \uc815\ub82c\ud574\uc11c 100\uac1c\uc758 \ubb38\uc11c\ub97c \ubc18\ud658\ud558\ub294\ub370 \ud398\uc774\uc9c0\uac00 \ub354 \uae4a\uc5b4\uc9c0\uba74 \uacb0\uad6d \uac80\uc0c9\uc5d0 \ucc38\uc5ec\ud558\ub294 \ubaa8\ub4e0 \ub178\ub4dc\uac00 \uba54\ubaa8\ub9ac\ubd80\uc871\uc73c\ub85c \uc8fd\uac8c \ub429\ub2c8\ub2e4.<\/p>\n<h2>\ud574\uacb0\ucc45<\/h2>\n<ul>\n<li>\n<p>\uc6d0\ud558\ub294 \uacb0\uacfc\ub97c 1~5 \ud398\uc774\uc9c0\uc5d0\uc11c \ucc3e\uc744 \uc218 \uc788\ub3c4\ub85d score \ub97c \uc798 \uc0b0\uc815\ud55c\ub2e4.<\/p>\n<\/li>\n<li>\n<p>\uc77c\uc815 \ud398\uc774\uc9c0 \uc774\uc0c1\uc73c\ub85c \ub4e4\uc5b4\uac08 \uc218 \uc5c6\ub3c4\ub85d \ub9c9\ub294\ub2e4.<\/p>\n<p>\uad6c\uae00\uc740 28 \ud398\uc774\uc9c0(\uac80\uc0c9\uacb0\uacfc 280\uac1c)\ub97c \ub118\ub294 \uacb0\uacfc\ub97c \ud45c\uc2dc\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uacb0\uacfc\uc14b\uc758 \ucd5c\ub300\uac12\uc740 <code>index.max_result_window<\/code> \uc5d0 \uc758\ud574 \uacb0\uc815\ub418\uace0 \ub514\ud3f4\ud2b8\uac12\uc740 10000 \uc778\ub370, \uc774 \uac12\uc744 \uc904\uc5ec\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>search_after<\/p>\n<\/li>\n<\/ul>\n<p><code>search_after<\/code> \uae30\ub2a5\uc744 \uc774\uc6a9\ud574 \ud398\uc774\uc9d5\uacfc \uc720\uc0ac\ud55c \uae30\ub2a5\uc744 \uc218\ud589\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>sort<\/code> \ub97c \ud3ec\ud568\ud574\uc57c \ud558\uace0, <code>sort<\/code> \uc5d0 \ud3ec\ud568\ub41c \ud30c\ub77c\ubbf8\ud130 \uc911 \ud558\ub098\ub294 Unique Key \uc774\uc5b4\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -X GET &quot;localhost:9200\/items\/_search?pretty&quot; -H &#039;Content-Type: application\/json&#039; -d&#039;{\n    &quot;size&quot;: 2,\n    &quot;query&quot;: {\n        &quot;match&quot; : {\n            &quot;itemname&quot; : &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n        }\n    },\n    &quot;sort&quot;: [\n        {&quot;lastupdate&quot;: &quot;desc&quot;},\n        {&quot;itemid&quot;: &quot;asc&quot;}\n    ]\n}&#039;<\/code><\/pre>\n<p>\uac80\uc0c9\uacb0\uacfc\uc5d0 <code>sort<\/code> \uac00 \ud3ec\ud568\ub41c \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-json\">{\n  &quot;took&quot; : 7,\n  &quot;timed_out&quot; : false,\n  &quot;_shards&quot; : {\n    &quot;total&quot; : 5,\n    &quot;successful&quot; : 5,\n    &quot;skipped&quot; : 0,\n    &quot;failed&quot; : 0\n  },\n  &quot;hits&quot; : {\n    &quot;total&quot; : 62,\n    &quot;max_score&quot; : null,\n    &quot;hits&quot; : [\n      {\n        &quot;_index&quot; : &quot;items_20200630112027702310&quot;,\n        &quot;_type&quot; : &quot;_doc&quot;,\n        &quot;_id&quot; : &quot;1439684&quot;,\n        &quot;_score&quot; : null,\n        &quot;_source&quot; : {\n          &quot;lastupdate&quot; : &quot;2020-06-30T11:21:57.000Z&quot;,\n          &quot;itemname&quot; : &quot;[DISNEY]\ub514\uc988\ub2c8 \uce74\ub4dc\uc218\ub0a9 \uc2a4\uc719 \ucda9\uaca9\ud761\uc218 \ucf00\uc774\uc2a4(\uc544\uc774\ud3f0\ucf00\uc774\uc2a4)&quot;,\n          &quot;@timestamp&quot; : &quot;2020-06-30T11:23:19.069Z&quot;,\n          &quot;price&quot; : 3000.0,\n          &quot;regdate&quot; : &quot;2020-06-27T07:13:11.000Z&quot;,\n          &quot;itemid&quot; : 1439684,\n          &quot;category&quot; : &quot;\ud558\ub4dc \ucf00\uc774\uc2a4\\r&quot;\n        },\n        &quot;sort&quot; : [\n          1593516117000,\n          1439684\n        ]\n      },\n      {\n        &quot;_index&quot; : &quot;items_20200630112027702310&quot;,\n        &quot;_type&quot; : &quot;_doc&quot;,\n        &quot;_id&quot; : &quot;1452585&quot;,\n        &quot;_score&quot; : null,\n        &quot;_source&quot; : {\n          &quot;lastupdate&quot; : &quot;2020-06-30T11:21:57.000Z&quot;,\n          &quot;itemname&quot; : &quot;[MST]\ud50c\ub77c\uc6cc \ud578\ub4dc\ubc31 \ud37c\ub2c8\ucf00\uc774\uc2a4(\uc544\uc774\ud3f0\ucf00\uc774\uc2a4)&quot;,\n          &quot;@timestamp&quot; : &quot;2020-06-30T11:22:19.668Z&quot;,\n          &quot;price&quot; : 3000.0,\n          &quot;regdate&quot; : &quot;2020-06-27T07:13:11.000Z&quot;,\n          &quot;itemid&quot; : 1452585,\n          &quot;category&quot; : &quot;\uc18c\ud504\ud2b8\/\uc2e4\ub9ac\ucf58 \ucf00\uc774\uc2a4\\r&quot;\n        },\n        &quot;sort&quot; : [\n          1593516117000,\n          1452585\n        ]\n      }\n    ]\n  }\n}<\/code><\/pre>\n<p>\ud3ec\ud568\ub418\uc5b4 \uc788\ub294 \ub9c8\uc9c0\ub9c9 <code>sort<\/code> \uc758 \uac12\uc744 \uc544\ub798\uc640 \uac19\uc774 <code>search_after<\/code> \uc5d0 \ucd94\uac00\ud558\uc5ec \uac80\uc0c9\ud558\uba74, \uc704\uc758 \uac80\uc0c9\uacb0\uacfc \uc774\ud6c4\uc758 \ubb38\uc11c\ub97c \ubc18\ud658\ubc1b\uac8c \ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -X GET &quot;localhost:9200\/items\/_search?pretty&quot; -H &#039;Content-Type: application\/json&#039; -d&#039;{\n    &quot;search_after&quot;: [1593516117000, 1452585],\n    &quot;size&quot;: 2,\n    &quot;query&quot;: {\n        &quot;match&quot; : {\n            &quot;itemname&quot; : &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n        }\n    },\n    &quot;sort&quot;: [\n        {&quot;lastupdate&quot;: &quot;desc&quot;},\n        {&quot;itemid&quot;: &quot;asc&quot;}\n    ]\n}&#039;<\/code><\/pre>\n<p>\uc704 \uae30\ub2a5\uc73c\ub85c \ub2e4\uc74c \ud398\uc774\uc9c0 \ub2e4\uc74c \ud398\uc774\uc9c0 \uc758 \ud615\uc2dd\uc73c\ub85c \ud398\uc774\uc9d5\uacfc \uc720\uc0ac\ud55c \uae30\ub2a5\uc744 \uc218\ud589\ud558\uac8c \ub429\ub2c8\ub2e4.<\/p>\n<p>\uadf8\ub7ec\uba74, \uc774\uc804 \ud398\uc774\uc9c0 \ub610\ub294 \ud604\uc7ac \ud398\uc774\uc9c0\uc5d0\uc11c 5\ud398\uc774\uc9c0 \uc55e\uc758 \ud398\uc774\uc9c0\ub294 \uc5b4\ub5bb\uac8c \uad6c\ud574\uc57c \ud560\uae4c\uc694?<\/p>\n<ul>\n<li>\n<p>Random access with search_after<\/p>\n<p><a href=\"https:\/\/rabbitoncode.com\/big-data\/2019\/10\/12\/pagination-elasticsearch\/\">\ucc38\uc870<\/a><\/p>\n<p>search_after \uc5d0\uc11c \uc4f0\uc774\ub294 \ud30c\ub77c\ubbf8\ud130\ub97c \ubbf8\ub9ac \uad6c\ud574\uc11c \uc800\uc7a5\ud574 \ub193\uace0, \uc800\uc7a5\ub418\uc5b4 \uc788\ub294 \ud30c\ub77c\ubbf8\ud130\ub97c \uc774\uc6a9\ud574 \uac01 \ud398\uc774\uc9c0\uc5d0 \uc811\uc18d\ud558\ub294 \uc544\uc774\ub514\uc5b4\uc785\ub2c8\ub2e4.<\/p>\n<p>\ud558\uc9c0\ub9cc \uc800\uc7a5\ud574 \ub193\uc740 \ud30c\ub77c\ubbf8\ud130\ub97c \uacc4\uc18d \uc5c5\ub370\uc774\ud2b8\ud574\uc57c \ud558\ub294\uac8c \uc27d\uc9c0 \uc54a\uaca0\ub124\uc694.<\/p>\n<\/li>\n<\/ul>\n<h2>\ube44\uace0<\/h2>\n<p>GS SHOP \uc740 \ucfe8\ud558\uac8c <a href=\"https:\/\/www.gsshop.com\/shop\/search\/main.gs?tq=%EA%B0%A4%EB%9F%AD%EC%8B%9C&amp;rq=&amp;cls=&amp;eh=eyJwYWdlTnVtYmVyIjozMDExLCJzZWxlY3RlZCI6Im9wdC1wYWdlIn0%3D\">18\ub9cc\uac1c\uc758 \uacb0\uacfc<\/a> \ub97c \ub2e4 \ud45c\uc2dc\ud558\ub124\uc694.<\/p>\n<p>\uc544\ub9c8 scroll api \ub97c \uc0ac\uc6a9\ud55c \ub4ef \ud569\ub2c8\ub2e4. \uc544\ub2c8\uba74&#8230; \uba38\uc2e0 \uc2a4\ud399\uc744 \ub9ce\uc774 \ub298\ub838\ub358\uc9c0&#8230; \ud6d4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Elasticsearch deep paging \ubb38\uc81c \ubb38\uc81c\uc810 \ud398\uc774\uc9c0 \uc0ac\uc774\uc988\uac00 100 \uc774\uace0, 30 \ud398\uc774\uc9c0\ub97c \uac80\uc0c9\ud558\ub824\uace0 \ud558\uba74, 3000 \uac1c\uc758 \ubb38\uc11c\ub97c \uc815\ub82c\ud574\uc57c \ud558\uace0 \uadf8 \ub2e4\uc74c\uc5d0 \ub9c8\uc9c0\ub9c9 100 \uac1c\uc758 \ubb38\uc11c\ub97c \ubc18\ud658\ud558\uac8c \ub429\ub2c8\ub2e4. \uc774 \ubb38\uc81c\ub294 \ub354 \uae4a\uc774 50 \ud398\uc774\uc9c0 200 \ud398\uc774\uc9c0\ub85c \ub4e4\uc5b4\uac08 \uc218\ub85d \ub354 \ub9ce\uc740 \uba54\ubaa8\ub9ac\ub97c \uc0ac\uc6a9\ud574\uc57c \ud558\uace0 \uacb0\uad6d\uc740 Elasticsearch \uac00 \uc8fd\ub294 \uacb0\uacfc\ub97c \uac00\uc838\uc635\ub2c8\ub2e4. \uc778\ub371\uc2a4\uac00 \uc5ec\ub7ec \uac1c\ub85c \ub098\ub258\uc5b4 \uc788\ub294 \uacbd\uc6b0, \uac01 \uc0e4\ub4dc\ubcc4\ub85c\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=1080\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1080","post","type-post","status-publish","format-standard","hentry","category-elasticsearch"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1080"}],"version-history":[{"count":20,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1080\/revisions"}],"predecessor-version":[{"id":1100,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1080\/revisions\/1100"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}