{"id":7261,"date":"2022-12-21T12:27:06","date_gmt":"2022-12-21T03:27:06","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=7261"},"modified":"2022-12-23T11:42:19","modified_gmt":"2022-12-23T02:42:19","slug":"elasticsearch-function_score","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=7261","title":{"rendered":"ElasticSearch &#8211; function_score"},"content":{"rendered":"<h1>ElasticSearch &#8211; function_score<\/h1>\n<p><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/query-dsl-function-score-query.html\">\ucc38\uc870<\/a><\/p>\n<p>\uc544\ub798 \ub0b4\uc6a9\uc740 \uc704 \ub9c1\ud06c\uc758 \ub0b4\uc6a9\uc744 \ub0b4 \ub9d8\ub300\ub85c \uc815\ub9ac\ud55c \ub0b4\uc6a9\uc785\ub2c8\ub2e4.<\/p>\n<h2>\uae30\ubcf8 \uc124\uc815<\/h2>\n<p><code>function_score<\/code> \ub294 \ud558\ub098\uc758 <code>query<\/code> \uc640 \ud558\ub098 \uc774\uc0c1\uc758 <code>score function<\/code> \uc73c\ub85c \uad6c\uc131\ub429\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;5&quot;,\n      &quot;random_score&quot;: {},\n      &quot;boost_mode&quot;: &quot;multiply&quot;\n    }\n  }\n}<\/code><\/pre>\n<p>\uc704\uc5d0\uc11c\ub294 \ub9e4\uce6d\ub418\ub294 \ubb38\uc11c\uc5d0 \ub300\ud574 5 \ub97c boost \ud558\uace0,<br \/>\n<code>random_score<\/code> \ud568\uc218\ub85c \uc0dd\uc131\ub41c \uac12\uc744 \uacf1\ud574\uc90d\ub2c8\ub2e4.(multiply)<\/p>\n<h2>score function<\/h2>\n<p><code>score function<\/code> \uc740 \uc544\ub798\uc640 \uac19\uc740 \ub2e4\uc591\ud55c \ud568\uc218\uac00 \uc874\uc7ac\ud569\ub2c8\ub2e4.<\/p>\n<ul>\n<li>script_score<\/li>\n<li>weight<\/li>\n<li>random_score<\/li>\n<li>field_value_factor<\/li>\n<li>decay functions: gauss, linear, exp<\/li>\n<\/ul>\n<h2>\ub450\uac1c \uc774\uc0c1\uc758 score function<\/h2>\n<p>\uc5ec\ub7ec\uac1c\uc758 <code>score function<\/code> \uc744 \uc870\ud569\ud574\uc11c \uac80\uc0c9\ud560 \uc218\ub3c4 \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    }\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ElasticSearch &#8211; function_score \ucc38\uc870 \uc544\ub798 \ub0b4\uc6a9\uc740 \uc704 \ub9c1\ud06c\uc758 \ub0b4\uc6a9\uc744 \ub0b4 \ub9d8\ub300\ub85c \uc815\ub9ac\ud55c \ub0b4\uc6a9\uc785\ub2c8\ub2e4. \uae30\ubcf8 \uc124\uc815 function_score \ub294 \ud558\ub098\uc758 query \uc640 \ud558\ub098 \uc774\uc0c1\uc758 score function \uc73c\ub85c \uad6c\uc131\ub429\ub2c8\ub2e4. { &quot;query&quot;: { &quot;function_score&quot;: { &quot;query&quot;: { &quot;match_all&quot;: {} }, &quot;boost&quot;: &quot;5&quot;, &quot;random_score&quot;: {}, &quot;boost_mode&quot;: &quot;multiply&quot; } } } \uc704\uc5d0\uc11c\ub294 \ub9e4\uce6d\ub418\ub294 \ubb38\uc11c\uc5d0 \ub300\ud574 5 \ub97c boost \ud558\uace0, random_score \ud568\uc218\ub85c\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=7261\">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-7261","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\/7261","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=7261"}],"version-history":[{"count":4,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7261\/revisions"}],"predecessor-version":[{"id":7267,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7261\/revisions\/7267"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}