{"id":991,"date":"2020-06-22T23:42:51","date_gmt":"2020-06-22T14:42:51","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=991"},"modified":"2020-07-02T22:05:07","modified_gmt":"2020-07-02T13:05:07","slug":"elasticsearch-search","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=991","title":{"rendered":"Elasticsearch search"},"content":{"rendered":"<h1>Elasticsearch search<\/h1>\n<p><code>match_all<\/code>, <code>match<\/code>, <code>match_phrase<\/code> \uc5d0 \ub300\ud574 \uc815\ub9ac\ud569\ub2c8\ub2e4.<\/p>\n<h2>match_all<\/h2>\n<p>\ubaa8\ub4e0 \ubb38\uc11c\uc640 \ub9e4\uce6d\ub429\ub2c8\ub2e4. \uac80\uc0c9\uc774\uc678\uc5d0 \uc544\ubb34 \uacc4\uc0b0\ub3c4 \ud558\uc9c0 \uc54a\uc73c\ubbc0\ub85c \uc18d\ub3c4\uac00 \ube60\ub985\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;{\n  &quot;query&quot;: {\n      &quot;match_all&quot;: {}\n  }\n}&#039;<\/code><\/pre>\n<p><code>_source<\/code> \uc758 \uc77c\ubd80\ub9cc \ubc18\ud658\ud558\uac8c \uc9c0\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;{\n  &quot;query&quot;: {\n      &quot;match_all&quot;: {}\n  },\n  &quot;_source&quot;: [&quot;itemname&quot;, &quot;viewkeywords&quot;, &quot;buykeywords&quot;]\n}&#039;<\/code><\/pre>\n<p>\ud398\uc774\uc9d5\uc744 \uc9c0\uc6d0\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;{\n  &quot;query&quot;: {\n      &quot;match_all&quot;: {}\n  },\n  &quot;from&quot;: 2,\n  &quot;size&quot;: 2\n}&#039;<\/code><\/pre>\n<p>\uc815\ub82c\uc21c\uc11c\ub97c \ubcc0\uacbd\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;{\n  &quot;query&quot;: {\n      &quot;match_all&quot;: {}\n  },\n  &quot;sort&quot;: [\n    {&quot;lastupdate&quot;: &quot;desc&quot;}\n  ]\n}&#039;<\/code><\/pre>\n<h2>match<\/h2>\n<p><code>match<\/code> \ub294 \uac80\uc0c9\uc5b4\ub97c \ud615\ud0dc\uc18c\ubd84\uc11d \ud6c4 \ub098\uc628 \ub2e8\uc5b4\uc911 \ud558\ub098\ub77c\ub3c4 \uc77c\uce58\ud558\ub294 \ubb38\uc11c\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;\n{\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n    }\n  }\n}&#039;<\/code><\/pre>\n<p>\uc544\ub798\uc758 \ucffc\ub9ac\ub85c \ud615\ud0dc\uc18c\ubd84\uc11d\ub41c \ubaa8\ub4e0 \ub2e8\uc5b4\uac00 \ub4f1\uc7a5\ud558\ub294 \ubb38\uc11c\ub97c \uac80\uc0c9\ud558\ub3c4\ub85d \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;\n{\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;itemname&quot;: {\n        &quot;query&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;,\n        &quot;operator&quot;: &quot;and&quot;\n      }\n    }\n  }\n}&#039;<\/code><\/pre>\n<p>\ud558\uc704 \ud544\ub4dc\ub97c \uac80\uc0c9\ud558\uae30 \uc704\ud574\uc11c\ub294 \uc544\ub798\uc640 \uac19\uc774 <code>itemname.ko<\/code> \ub97c \uc785\ub825\ud558\uba74 \ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;\n{\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;itemname.ko&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n    }\n  }\n}&#039;<\/code><\/pre>\n<h2>multi_match<\/h2>\n<p>\uc5ec\ub7ec \ud544\ub4dc\ub97c \ud55c\ubc88\uc5d0 \uac80\uc0c9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl &quot;localhost:9200\/items\/_search?pretty&quot; -H &quot;Content-Type:application\/json&quot; -d &#039;{\n  &quot;query&quot;: {\n    &quot;multi_match&quot;: { \n      &quot;query&quot;: &quot;\uc26c\ud3f0\ube14\ub77c\uc6b0\uc2a4&quot;, \n      &quot;fields&quot;: [&quot;itemname.ko&quot;, &quot;itemname.en&quot;]\n    }\n  }\n}&#039;<\/code><\/pre>\n<h2>match_phrase<\/h2>\n<p><code>match_phrase<\/code> \ub294 \uac80\uc0c9\uc5b4\ub97c \ud615\ud0dc\uc18c\ubd84\uc11d \ud6c4 \ub098\uc628 \ub2e8\uc5b4\uac00 \ubaa8\ub450 \ub4f1\uc7a5\ud558\uace0 \uc21c\uc11c\ub3c4 \uc77c\uce58\ud558\ub294 \ubb38\uc11c\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XPOST &#039;localhost:9200\/items\/_analyze?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;\n{\n  &quot;analyzer&quot;: &quot;korean&quot;,\n  &quot;text&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n}&#039;\n\ncurl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;match_phrase&quot;: {\n      &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n    }\n  }\n}&#039;<\/code><\/pre>\n<h2>_termvectors<\/h2>\n<p><code>_termvectors<\/code> \ub97c \uc774\uc6a9\ud574 \ud544\ub4dc\uc5d0\uc11c \uac00\uc9c0\uace0 \uc788\ub294 term \uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_doc\/1\/_termvectors?fields=itemname&amp;pretty&#039;<\/code><\/pre>\n<h2>bool \ucffc\ub9ac<\/h2>\n<p><code>must<\/code>, <code>must_not<\/code>, <code>should<\/code>, <code>filter<\/code> \ub97c \uc774\uc6a9\ud574 \ubcf5\uc7a1\ud55c \ucffc\ub9ac\ub97c \uc0dd\uc131\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\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      &quot;filter&quot;: [\n        { &lt;\ucffc\ub9ac&gt; }, \u2026\n      ]\n    }\n  }\n}&#039;<\/code><\/pre>\n<h3>must<\/h3>\n<p>\ub9e4\uce6d\ud558\ub294 \ubb38\uc11c\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;must&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0&quot;\n          }\n        },\n        {\n          &quot;match_phrase&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n          }\n        }\n      ]\n    }\n  }\n}&#039;<\/code><\/pre>\n<h3>must_not<\/h3>\n<p>\ub9e4\uce6d\ud558\uc9c0 \uc54a\ub294 \ubb38\uc11c\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;must_not&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0&quot;\n          }\n        },\n        {\n          &quot;match_phrase&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0\ucf00\uc774\uc2a4&quot;\n          }\n        }\n      ]\n    }\n  }\n}&#039;<\/code><\/pre>\n<h3>should<\/h3>\n<p>\ub9e4\uce6d\ud558\ub294 \ubb38\uc11c\uc758 score \ub97c \uc62c\ub824\uc90d\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;must&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0&quot;\n          }\n        }\n      ],\n      &quot;should&quot;: [\n        {\n          &quot;match_phrase&quot;: {\n            &quot;itemname&quot;: &quot;\ud551\ud06c&quot;\n          }\n        }\n      ]\n    }\n  }\n}&#039;<\/code><\/pre>\n<h3>filter<\/h3>\n<p>\ub9e4\uce6d\ud558\ub294 \ubb38\uc11c\ub97c \ubc18\ud658\ud558\uc9c0\ub9cc score \ub97c \uacc4\uc0b0\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;must&quot;: { &quot;match_all&quot;: {} },\n      &quot;filter&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0&quot;\n          }\n        }\n      ],\n      &quot;must&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;\uc544\uc774\ud3f0&quot;\n          }\n        }\n      ],\n      &quot;should&quot;: [\n        {\n          &quot;match_phrase&quot;: {\n            &quot;itemname&quot;: &quot;\ud551\ud06c&quot;\n          }\n        }\n      ]\n    }\n  }\n}&#039;<\/code><\/pre>\n<p><strong>\uce90\uc2dc\uac00 \ub418\ubbc0\ub85c, \ub2e4\ub978 \uac80\uc0c9\uae30\ub2a5\uc5d0 \uc55e\uc11c \uc0ac\uc6a9\ud558\uba74 \uc18d\ub3c4\uac1c\uc120\uc5d0 \ub3c4\uc6c0\uc774 \ub429\ub2c8\ub2e4.<\/strong><\/p>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;bool&quot;: {\n      &quot;must&quot;: { &quot;match_all&quot;: {} },\n      &quot;filter&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;wpc\uc7a5\uc6b0\uc0b0&quot;\n          }\n        }\n      ],\n      &quot;must&quot;: [\n        {\n          &quot;match&quot;: {\n            &quot;itemname&quot;: &quot;\uac80\uc815\uc7a5\uc6b0\uc0b0&quot;\n          }\n        }\n      ],\n      &quot;should&quot;: [\n        {\n          &quot;match_phrase&quot;: {\n            &quot;itemname&quot;: {\n              &quot;query&quot;: &quot;wpc&quot;,\n              &quot;slop&quot;:  2\n            }\n          }\n        }\n      ]\n    }\n  }\n}&#039;<\/code><\/pre>\n<h2>\ubc94\uc704 \ucffc\ub9ac<\/h2>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;range&quot;: {\n      &quot;price&quot;: {\n        &quot;gte&quot;: 700,\n        &quot;lt&quot;: 900\n      }\n    }\n  }\n}&#039;<\/code><\/pre>\n<pre><code class=\"language-bash\">curl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;range&quot;: {\n      &quot;date&quot;: {\n        &quot;gt&quot;: &quot;2016-01-01&quot;\n      }\n    }\n  }\n}&#039;\n\n\uc544\ub798\uc640 \uac19\uc774 \ud0c0\uc784\uc874\uc744 \uc9c0\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n\ncurl -XGET &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d &#039;{\n  &quot;query&quot;: {\n    &quot;range&quot;: {\n      &quot;date&quot;: {\n        &quot;gt&quot;: &quot;2020-06-30T15:00:00+09:00&quot;\n      }\n    }\n  }\n}&#039;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Elasticsearch search match_all, match, match_phrase \uc5d0 \ub300\ud574 \uc815\ub9ac\ud569\ub2c8\ub2e4. match_all \ubaa8\ub4e0 \ubb38\uc11c\uc640 \ub9e4\uce6d\ub429\ub2c8\ub2e4. \uac80\uc0c9\uc774\uc678\uc5d0 \uc544\ubb34 \uacc4\uc0b0\ub3c4 \ud558\uc9c0 \uc54a\uc73c\ubbc0\ub85c \uc18d\ub3c4\uac00 \ube60\ub985\ub2c8\ub2e4. curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;{ &quot;query&quot;: { &quot;match_all&quot;: {} } }&#039; _source \uc758 \uc77c\ubd80\ub9cc \ubc18\ud658\ud558\uac8c \uc9c0\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. curl -XPOST &#039;localhost:9200\/items\/_search?pretty&#039; -H &#039;Content-Type: application\/json&#039; -d&#039;{ &quot;query&quot;: { &quot;match_all&quot;: {} }, &quot;_source&quot;: [&quot;itemname&quot;, &quot;viewkeywords&quot;, &quot;buykeywords&quot;]\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=991\">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-991","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\/991","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=991"}],"version-history":[{"count":24,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":1075,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/991\/revisions\/1075"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}