{"id":6017,"date":"2022-08-17T17:23:41","date_gmt":"2022-08-17T08:23:41","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6017"},"modified":"2023-01-26T18:15:19","modified_gmt":"2023-01-26T09:15:19","slug":"elasticsearch-query-dsl","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6017","title":{"rendered":"Elasticsearch Query DSL"},"content":{"rendered":"<h1>Elasticsearch Query DSL<\/h1>\n<h2>\uc0ac\uc6a9\ud558\ub294 \ud234<\/h2>\n<p><a href=\"https:\/\/chrome.google.com\/webstore\/detail\/multi-elasticsearch-head\/cpmmilfkofbeimbmgiclohpodggeheim\">Multi Elasticsearch Head<\/a> \ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4.<\/p>\n<p>\ud0a4\ubc14\ub098 \uc5c6\uc774 \ucffc\ub9ac\uacb0\uacfc\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc5b4 \ud3b8\ub9ac\ud569\ub2c8\ub2e4.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2022\/08\/2022-08-17-01.png\" alt=\"\" \/><\/p>\n<h2>Full Text Query<\/h2>\n<h3>match_all<\/h3>\n<p>\ubaa8\ub4e0 \ubb38\uc11c\uac00 \ub9e4\uce6d\ub429\ub2c8\ub2e4.<br \/>\n\uc544\ubb34 \uac80\uc0c9\uc870\uac74\uc744 \ub123\uc9c0 \uc54a\uc73c\uba74 \uc790\ub3d9\uc73c\ub85c <code>match_all<\/code> \ub85c \uac80\uc0c9\ub429\ub2c8\ub2e4.<\/p>\n<p>API \ub85c \ud638\ucd9c\ub420 \uacbd\uc6b0 <code>match_all<\/code> \uc774 \uc790\ub3d9\uc73c\ub85c \ud3ec\ud568\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<br \/>\n\uba85\uc2dc\uc801\uc73c\ub85c \ub123\uc5b4\uc8fc\uc5b4\uc57c \ud558\uba70, \ub123\uc9c0 \uc54a\uc73c\uba74 \uc5b4\ub5a4 \ubb38\uc11c\ub3c4 \ubc18\ud658\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;:{\n    &quot;match_all&quot;:{ }\n  }\n}<\/code><\/pre>\n<h3>match<\/h3>\n<p>\ud2b9\uc815 \ub2e8\uc5b4\ub97c \uac80\uc0c9\ud569\ub2c8\ub2e4.<br \/>\ntext \ud544\ub4dc\ub97c \uc81c\uc678\ud558\uace0, \ubaa8\ub450 \uc815\ud655\ud788 \uc77c\uce58\ud558\ub294 \ub370\uc774\ud0c0\ub9cc \ubc18\ud658\ud569\ub2c8\ub2e4.<br \/>\ntext \ud544\ub4dc\uc758 \uacbd\uc6b0, \ud615\ud0dc\uc18c \ubd84\uc11d\ub41c \ub2e8\uc5b4\uac00 \uc815\ud655\ud788 \uc77c\uce58\ud560 \ub54c\ub9cc \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;message&quot;: &quot;dog&quot;\n    }\n  }\n}<\/code><\/pre>\n<p>\ub450\uac1c \uc774\uc0c1\uc758 \ub2e8\uc5b4\ub97c \uac80\uc0c9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br \/>\noperator \ub294 and \ub610\ub294 or \uac00 \uac00\ub2a5\ud558\uba70, \uc0dd\ub7b5\uc2dc or \uc870\uac74\uc73c\ub85c \uac80\uc0c9\ub429\ub2c8\ub2e4.<\/p>\n<p>\uac01 \ub2e8\uc5b4\ub294 <code>match<\/code> \uc640 \ub3d9\uc77c\ud558\uac8c \uac80\uc0c9\uacb0\uacfc\ub97c \ubc18\ud658\ud558\uba70,<br \/>\n\uc21c\uc11c\ub294 \uc0c1\uad00\uc5c6\uc2b5\ub2c8\ub2e4.<\/p>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;message&quot;: {\n        &quot;query&quot;: &quot;quick dog&quot;,\n        &quot;operator&quot;: &quot;and&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<h3>match_phrase<\/h3>\n<p>\ub2e8\uc5b4\uc758 \uc21c\uc11c\uae4c\uc9c0 \uac80\uc0c9\uc870\uac74\uc5d0 \ud3ec\ud568\ub418\uba70,<br \/>\n\uc911\uac04\uc5d0 \ub2e4\ub978 \ub2e8\uc5b4\uc758 \uc874\uc7ac\ub3c4 \ud5c8\uc6a9\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;match_phrase&quot;: {\n      &quot;message&quot;: &quot;lazy dog&quot;\n    }\n  }\n}<\/code><\/pre>\n<p><code>slop<\/code> \uc774\ub77c\ub294 \uc635\uc158\uc73c\ub85c,<br \/>\n\uc911\uac04\uc5d0 \ub07c\uc5b4\ub4e4 \uc218 \uc788\ub294 \ub2e8\uc5b4\uc758 \uc218\ub97c \uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;match_phrase&quot;: {\n      &quot;message&quot;: {\n        &quot;query&quot;: &quot;lazy dog&quot;,\n        &quot;slop&quot;: 1\n      }\n    }\n  }\n}<\/code><\/pre>\n<h2>Bool Query<\/h2>\n<ul>\n<li>\n<p>filter<\/p>\n<p>\ub9e4\uce6d\uc5ec\ubd80\ub9cc \ud310\ub2e8\ud558\uace0 score \ub97c \ub9e4\uae30\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<br \/>\ncache \uac00 \ub418\ubbc0\ub85c \ub2e4\ub978 \uac80\uc0c9\uc870\uac74\uc5d0 \uc55e\uc11c \ubc30\uce58\ud569\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>must<\/p>\n<p>\uc77c\uce58\ud558\ub294 \ubb38\uc11c\ub9cc \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>must_not<\/p>\n<p>\uc77c\uce58\ud558\uc9c0 \uc54a\ub294 \ubb38\uc11c\ub9cc \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>should<\/p>\n<p>\uc77c\uce58\ud558\ub294 \ubb38\uc11c\uc758 score \ub97c \ub192\uc5ec\uc90d\ub2c8\ub2e4.<\/p>\n<\/li>\n<\/ul>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;filter&quot;: [\n        { &lt;\ucffc\ub9ac&gt; }, \u2026\n      ],\n      &quot;must&quot;: [\n        { &lt;\ucffc\ub9ac&gt; }, \u2026\n      ],\n      &quot;must_not&quot;: [\n        { &lt;\ucffc\ub9ac&gt; }, \u2026\n      ],\n      &quot;should&quot;: [\n        { &lt;\ucffc\ub9ac&gt; }, \u2026\n      ]\n    }\n  }\n}<\/code><\/pre>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;must&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;message&quot;: &quot;quick&quot;\n          }\n        },\n        {\n          &quot;match_phrase&quot;: {\n            &quot;message&quot;: &quot;lazy dog&quot;\n          }\n        }\n      ]\n    }\n  }\n}<\/code><\/pre>\n<h2>Bool Query \uc608\uc81c<\/h2>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;filter&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;message&quot;: {\n              &quot;query&quot;: &quot;dog&quot;\n            }\n          }\n        },\n        {\n          &quot;bool&quot;: {\n            &quot;must_not&quot;: [\n              {\n                &quot;match&quot;: {\n                  &quot;message&quot;: &quot;fox&quot;\n                }\n              }\n            ]\n          }\n        }\n      ],\n      &quot;must&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;message&quot;: {\n              &quot;query&quot;: &quot;lazy dog&quot;\n            }\n          }\n        }\n      ],\n      &quot;should&quot;: [\n        {\n          &quot;match_phrase&quot;: {\n            &quot;message&quot;: &quot;lazy dog&quot;\n          }\n        }\n      ]\n    }\n  }\n}<\/code><\/pre>\n<h2>Range<\/h2>\n<p>Data Type \uc774 keyword, numeric, date \uc778\uacbd\uc6b0,<br \/>\n\uac80\uc0c9\uc870\uac74\uc5d0 \ubd80\ud569\ud558\ub294\uc9c0 true\/false \ub9cc \uc874\uc7ac\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc774\ub7f0 \uc870\uac74\ub4e4\uc740 <code>Bool : Filter<\/code> \uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4.<\/p>\n<p>GET my_index\/_search<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;filter&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;isUsing&quot;: &quot;Y&quot;\n          }\n        },\n        {\n          &quot;match&quot;: {\n            &quot;sellStatus&quot;: &quot;Y&quot;\n          }\n        },\n        {\n          &quot;range&quot;: {\n            &quot;sellCash&quot;: {\n              &quot;gte&quot;: 10000,\n              &quot;lt&quot;: 20000\n            }\n          }\n        },\n        {\n          &quot;range&quot;: {\n            &quot;regDate&quot;: {\n              &quot;gte&quot;: &quot;2022-05-30&quot;\n            }\n          }\n        }\n      ]\n    }\n  }\n}<\/code><\/pre>\n<h2>Function Score Query<\/h2>\n<p>\uac80\uc0c9\uc5d4\uc9c4\uc774 \uc801\uc6a9\ub418\ub294 \ubd84\uc57c\uc5d0 \ub530\ub77c \uac00\uc911\uce58\ub97c \ucee4\uc2a4\ud130\ub9c8\uc774\uc9d5 \ud574\uc57c \ud558\ub294 \uacbd\uc6b0\uac00 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc774\ub7f4 \ub54c\ub294 Function Score Query \uac00 \uc0ac\uc6a9\ub429\ub2c8\ub2e4.<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=7261\">\ucc38\uc870<\/a><\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=7265\">\ucc38\uc870<\/a><\/p>\n<p>\ud2b9\uc815 \uc870\uac74\uc5d0 \ubd80\ud569\ud558\ub294 \ubb38\uc11c\uc758 \uac00\uc911\uce58\ub97c \uac01\uac01 \ub2e4\ub974\uac8c \ubd80\uc5ec\ud574\uc11c,<br \/>\n\ub9ac\uc2a4\ud2b8\uc5d0 \ud45c\uc2dc\ub418\ub294 \uc21c\uc11c\ub97c \ubcf4\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>function_score \ub294 \ud558\ub098\uc758 query \uc640 \ud558\ub098 \uc774\uc0c1\uc758 function \uc73c\ub85c \uad6c\uc131\ub429\ub2c8\ub2e4.<br \/>\nmin_score \ub97c \ubd80\uc5ec\ud574\uc11c \ubd88\ud544\uc694\ud55c \ubb38\uc11c\ub4e4\uc774 \ubaa9\ub85d\uc5d0 \ub4f1\uc7a5\ud558\ub294 \uac83\uc744 \uc81c\uac70\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-json\">{\n  &quot;query&quot;: {\n    &quot;function_score&quot;: {\n      &quot;query&quot;: {\n        &quot;match_all&quot;: {}\n      },\n      &quot;boost&quot;: &quot;1&quot;,\n      &quot;functions&quot;: [\n        {\n          &quot;filter&quot;: {\n            &quot;match&quot;: {\n              &quot;search_string.ngram&quot;: {\n                &quot;query&quot;: &quot;\uc544\uc774\ud3f0 \ucf00\uc774\uc2a4&quot;,\n                &quot;operator&quot;: &quot;AND&quot;,\n                &quot;analyzer&quot;: &quot;my_ngram_analyzer3&quot;\n              }\n            }\n          },\n          &quot;weight&quot;: 50\n        },\n        {\n          &quot;filter&quot;: {\n            &quot;match&quot;: {\n              &quot;search_string.ngram&quot;: {\n                &quot;query&quot;: &quot;\uc544\uc774\ud3f0 \ucf00\uc774\uc2a4&quot;,\n                &quot;operator&quot;: &quot;AND&quot;,\n                &quot;analyzer&quot;: &quot;my_ngram_analyzer2&quot;\n              }\n            }\n          },\n          &quot;weight&quot;: 40\n        },\n        {\n          &quot;filter&quot;: {\n            &quot;match&quot;: {\n              &quot;search_string.ngram&quot;: {\n                &quot;query&quot;: &quot;\uc544\uc774\ud3f0 \ucf00\uc774\uc2a4&quot;,\n                &quot;operator&quot;: &quot;AND&quot;,\n                &quot;analyzer&quot;: &quot;my_ngram_analyzer&quot;\n              }\n            }\n          },\n          &quot;weight&quot;: 30\n        },\n        {\n          &quot;filter&quot;: {\n            &quot;match&quot;: {\n              &quot;search_string.ngram&quot;: {\n                &quot;query&quot;: &quot;\uc544\uc774\ud3f0 \ucf00\uc774\uc2a4&quot;,\n                &quot;operator&quot;: &quot;OR&quot;,\n                &quot;analyzer&quot;: &quot;my_ngram_analyzer3&quot;\n              }\n            }\n          },\n          &quot;weight&quot;: 5\n        },\n        {\n          &quot;filter&quot;: {\n            &quot;match&quot;: {\n              &quot;search_string.ngram&quot;: {\n                &quot;query&quot;: &quot;\uc544\uc774\ud3f0 \ucf00\uc774\uc2a4&quot;,\n                &quot;operator&quot;: &quot;OR&quot;,\n                &quot;analyzer&quot;: &quot;my_ngram_analyzer2&quot;\n              }\n            }\n          },\n          &quot;weight&quot;: 4\n        },\n        {\n          &quot;filter&quot;: {\n            &quot;match&quot;: {\n              &quot;search_string.ngram&quot;: {\n                &quot;query&quot;: &quot;\uc544\uc774\ud3f0 \ucf00\uc774\uc2a4&quot;,\n                &quot;operator&quot;: &quot;OR&quot;,\n                &quot;analyzer&quot;: &quot;my_ngram_analyzer&quot;\n              }\n            }\n          },\n          &quot;weight&quot;: 3\n        }\n      ],\n      &quot;score_mode&quot;: &quot;sum&quot;,\n      &quot;boost_mode&quot;: &quot;multiply&quot;,\n      &quot;min_score&quot;: 42\n    }\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Elasticsearch Query DSL \uc0ac\uc6a9\ud558\ub294 \ud234 Multi Elasticsearch Head \ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \ud0a4\ubc14\ub098 \uc5c6\uc774 \ucffc\ub9ac\uacb0\uacfc\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc5b4 \ud3b8\ub9ac\ud569\ub2c8\ub2e4. Full Text Query match_all \ubaa8\ub4e0 \ubb38\uc11c\uac00 \ub9e4\uce6d\ub429\ub2c8\ub2e4. \uc544\ubb34 \uac80\uc0c9\uc870\uac74\uc744 \ub123\uc9c0 \uc54a\uc73c\uba74 \uc790\ub3d9\uc73c\ub85c match_all \ub85c \uac80\uc0c9\ub429\ub2c8\ub2e4. API \ub85c \ud638\ucd9c\ub420 \uacbd\uc6b0 match_all \uc774 \uc790\ub3d9\uc73c\ub85c \ud3ec\ud568\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uba85\uc2dc\uc801\uc73c\ub85c \ub123\uc5b4\uc8fc\uc5b4\uc57c \ud558\uba70, \ub123\uc9c0 \uc54a\uc73c\uba74 \uc5b4\ub5a4 \ubb38\uc11c\ub3c4 \ubc18\ud658\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. GET my_index\/_search { &quot;query&quot;:{ &quot;match_all&quot;:{\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6017\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-6017","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\/6017","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=6017"}],"version-history":[{"count":12,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6017\/revisions"}],"predecessor-version":[{"id":7523,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6017\/revisions\/7523"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}