{"id":550742,"date":"2021-12-29T19:35:04","date_gmt":"2021-12-29T11:35:04","guid":{"rendered":"http:\/\/4563.org\/?p=550742"},"modified":"2021-12-29T19:35:04","modified_gmt":"2021-12-29T11:35:04","slug":"elasticsearch-%e5%b5%8c%e5%a5%97%e6%96%87%e6%a1%a3%e6%9f%a5%e8%af%a2%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=550742","title":{"rendered":"elasticsearch \u5d4c\u5957\u6587\u6863\u67e5\u8be2\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1> elasticsearch \u5d4c\u5957\u6587\u6863\u67e5\u8be2\u95ee\u9898 <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CRUD <\/span>  <span><i><\/i> 11<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6c42\u95ee\u4e00\u4e2a es \u5d4c\u5957\u6587\u6863\u67e5\u8be2\uff0c\u4ec5\u5f53\u67e5\u8be2\u8303\u56f4\u5185\u6240\u6709\u5d4c\u5957\u6587\u6863\u90fd\u6ee1\u8db3\u6761\u4ef6\u65f6\u624d\u8fd4\u56de\uff0c\u800c\u4e0d\u662f\u53ea\u8981\u6709\u4e00\u4e2a\u5d4c\u5957\u6587\u6863\u6ee1\u8db3\u6761\u4ef6\u5c31\u8fd4\u56de\u3002<\/p>\n<p>\u6211\u7684\u573a\u666f\u662f\u6309\u5929\u5efa\u7acb\u5d4c\u5957\u6587\u6863\uff0c\u7b5b\u9009\u65f6\u7ed9\u5b9a\u65e5\u671f\u8303\u56f4\uff0c\u9700\u8981\u7b5b\u9009\u51fa\u8be5\u65e5\u671f\u8303\u56f4\u5185\u6bcf\u5929\u90fd\u6ee1\u8db3\u7b5b\u9009\u6761\u4ef6\u7684\u6587\u6863\uff0c\u76ee\u524d\u6211\u81ea\u5df1\u5199\u7684\u641c\u7d22\u8bed\u6cd5\u53ea\u8981\u65e5\u671f\u8303\u56f4\u5185\u6709\u4e00\u5929\u6ee1\u8db3\u5c31\u4f1a\u8fd4\u56de..<\/p>\n<p>\u6211\u7684\u6587\u6863\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre><code>{     \"mappings\": {         \"properties\": {             \"adResource\": {                 \"type\": \"nested\",                 \"properties\": {                     \"day\": {                         \"type\": \"date\",                         \"format\": \"yyyy-MM-dd || epoch_millis\"                     },                     \"total\": {                         \"type\": \"integer\"                     },                     \"subResource\": {                         \"type\": \"nested\",                         \"properties\": {                             \"hours\": {                                 \"type\": \"integer\"                             },                             \"total\": {                                 \"type\": \"integer\"                             }                         }                     }                 }             }         }     } } <\/code><\/pre>\n<p>\u6570\u636e\u793a\u4f8b\uff1a<\/p>\n<pre><code>{     \"adResource\": [         {             \"total\": 1800,             \"subResource\": [                 {                     \"hours\": 0,                     \"total\": 0                 },                 {                     \"hours\": 3600,                     \"total\": 0                 },                 {                     \"hours\": 7200,                     \"total\": 0                 },                 {                     \"hours\": ...,                     \"total\": ...                 },                 {                     \"hours\": 82800,                     \"total\": 0                 }             \"day\": \"2021-11-20\"         },         {            \"total\": 5200,            \"subResource\":[......]            \"day\": \"2021-11-21\"         }     ] } <\/code><\/pre>\n<p>\u9700\u6c42\uff1a\u68c0\u7d22\u7684\u65f6\u5019\u7ed9\u5b9a\u4e00\u4e2a\u65e5\u671f\u533a\u95f4\u548c\u5c0f\u65f6\u533a\u95f4\uff0c\u8981\u6c42\u68c0\u7d22\u51fa\u65e5\u671f\u533a\u95f4\u548c\u5c0f\u65f6\u533a\u95f4\u5185\u8d44\u6e90\u5168\u90e8\u6ee1\u8db3\u7684\u6587\u6863\uff0c\u4f8b\u5982\u7ed9\u5b9a\u68c0\u7d22\u6761\u4ef6\uff1a<\/p>\n<pre><code>{     \"dayStart\": \"2021-11-20\",     \"dayEnd\": \"2021-11-21\",     \"total\": 540,     \"subResource\": [         {             \"hour\": 0,             \"total\": 180         },         {             \"hour\": 3600, \/\/ hour 3600 \u8868\u793a 1:00:00 \u5230 1:59:59 \u7684\u533a\u95f4             \"total\": 360         }     ] } <\/code><\/pre>\n<p>\u8868\u793a 20 \u300121 \u8fd9\u4e24\u5929\u7684 total&gt;540 \uff0c\u4e14\u8fd9\u4e24\u5929\u5185\u7684 hour 0 &gt; 180 &amp;&amp; hour 3600 &gt; 360<\/p>\n<p>\u76ee\u524d\u7684\u641c\u7d22\u8bed\u6cd5\u5982\u4e0b\uff0c\u8be5\u641c\u7d22\u4f1a\u8fd4\u56de 20 \u300121 \u8fd9\u4e24\u5929\u53ea\u6709\u4e00\u5929\u6ee1\u8db3\u6761\u4ef6\u7684\u6587\u6863\uff0c\u800c\u6211\u9700\u8981\u7684\u662f\u4e24\u5929\u90fd\u6ee1\u8db3\u7684\u6587\u6863\uff1a<\/p>\n<pre><code>{   \"query\": {     \"bool\": {       \"filter\": [         {           \"nested\": {             \"path\": \"adResource\",             \"query\": {               \"bool\": {                 \"must\": [                   {                     \"range\": {                       \"adResource.day\": {                         \"gte\": \"2021-11-20\",                         \"lte\": \"2021-11-21\"                       }                     }                   },                   {                     \"nested\": {                       \"path\": \"adResource.subResource\",                       \"query\": {                         \"bool\": {                           \"must\": [                             {                               \"bool\": {                                 \"must\": [                                   {                                     \"term\": {                                       \"adResource.subResource.hours\": {                                         \"value\": \"0\"                                       }                                     }                                   },                                   {                                     \"range\": {                                       \"adResource.subResource.total\": {                                         \"gte\": 180                                       }                                     }                                   }                                 ]                               }                             },                             {                               \"bool\": {                                 \"must\": [                                   {                                     \"term\": {                                       \"adResource.subResource.hours\": {                                         \"value\": \"3600\"                                       }                                     }                                   },                                   {                                     \"range\": {                                       \"adResource.subResource.total\": {                                         \"gte\": 360                                       }                                     }                                   }                                 ]                               }                             }                           ]                         }                       }                     }                   }                 ]               }             }           }         }       ]     }   } } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>) <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"7122139\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Saxton <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> &#8221;&#8217;<br \/>{<br \/> &#8220;bool&#8221;:{<br \/> &#8220;must&#8221;:[<br \/> {<br \/> &#8220;term&#8221;:{<br \/> &#8220;adResource.subResource.hours&#8221;:{<br \/> &#8220;value&#8221;:&#8221;0&#8243;<br \/> }<br \/> }<br \/> },<br \/> {<br \/> &#8220;range&#8221;:{<br \/> &#8220;adResource.subResource.total&#8221;:{<br \/> &#8220;gte&#8221;:180<br \/> }<br \/> }<br \/> }<br \/> ]<br \/> }<br \/>}<br \/>&#8221;&#8217;<br \/>\u4e3a\u4ec0\u4e48\u8fd9\u91cc\u6709\u4e00\u4e2a &#8220;value&#8221;:&#8221;0&#8243; \u5462 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7122140\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Saxton <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> \u4f60\u60f3\u8981\u67e5\u8be2\u8868\u793a 20 \u300121 \u8fd9\u4e24\u5929\u7684 total&gt;540 \uff0c\u4e14\u8fd9\u4e24\u5929\u5185\u7684 hour 0 &gt; 180 &amp;&amp; hour 3600 &gt; 360 \uff0c\u89e3\u6790\u4e00\u4e0b\u4f60\u7684\u6761\u4ef6\uff0c20 \u300121 \u8fd9\u4e24\u5929\u7684 total&gt;540 \u8fd9\u4e2a\u4e3a\u5fc5\u8981\u6761\u4ef6\uff0c \u90a3\u4e48 hour 0 &gt; 180 &amp;&amp; hour 3600 &gt; 360 \u5e94\u8be5\u4e3a\u6216\u6761\u4ef6\uff0c\u800c\u4e0d\u662f\u4e14 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7122141\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : CRUD <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> @Saxton value 0 \u8868\u793a\u7684\u662f 00:00-00:59 \u8fd9\u6bb5\u65f6\u95f4\uff0c\u6211\u662f\u628a\u8ddd\u79bb 0 \u70b9\u7684\u79d2\u6570\u5f53\u505a\u4e86\u5c0f\u65f6\u7684 key \uff0c\u6bd4\u5982 0 \u8868\u793a 0 \u70b9\u5230 1 \u70b9\uff0c3600 \u8868\u793a 1 \u70b9\u5230 2 \u70b9\uff0c7200 \u8868\u793a 2 \u70b9\u5230 3 \u70b9\u3002<br \/>\u5b9e\u9645\u4e0a hour 0 &gt; 180 &amp;&amp; hour 3600 &gt; 360 \u4e5f\u662f\u4e3a\u4e14\u7684\uff0c\u56e0\u4e3a\u6211\u9700\u8981\u7684\u662f\u5728 0 \u70b9-1 \u70b9\uff0c1 \u70b9-2 \u70b9\u8fd9\u4e2a\u533a\u95f4\u90fd\u6ee1\u8db3\u7684\u6570\u636e\u3002 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7122142\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sadfQED2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> \u6211\u6700\u8fd1\u4e5f\u88ab es \u7684\u53cd\u4eba\u7c7b\u67e5\u8be2\u8bed\u6cd5\u6298\u817e\u5f97\u6b7b\u53bb\u6d3b\u6765\uff0c\u6700\u540e\u60f3\u4e86\u4e2a\u529e\u6cd5\uff0c\u5148\u7528 sql \u5199\u51fa\u67e5\u8be2\u8bed\u53e5\uff0c\u518d\u7528\u6700\u65b0\u7684 es sql api \u8f6c\u6210 dsl \u8bed\u53e5<br \/>https:\/\/xjiangwei.cn\/2021\/11\/23\/ES_DSL\/ <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7122143\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : morewe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> @sadfQED2 \u770b\u5230\u4f60\u8bf4\u88ab ES \u6298\u78e8\u7684\u60f3\u539f\u5730\u53bb\u4e16\u90a3\u53e5\u597d\u597d\u7b11\u3002^-^\u3002\u753b\u9762\u611f\u6251\u9762\u800c\u6765\u3002\u4e00\u65b9\u9762\u662f\u5927\u5bb6\u90fd\u6709 N \u6b21\u88ab\u4e00\u4e2a\u95ee\u9898\u6298\u78e8\u51e0\u5929\u7684\u7ecf\u5386\u6240\u4ee5\u80fd\u591f\u611f\u540c\u8eab\u53d7\uff0c\u4f46\u662f\u5f53\u81ea\u5df1\u4e0d\u88ab\u6298\u78e8\u65f6\u770b\u522b\u4eba\u88ab\u6298\u78e8\u5c31\u662f\u6709\u4e00\u79cd\u8be1\u5f02\u7684\u5feb\u4e50\u3002 <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>elasticsearch \u5d4c\u5957\u6587&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/550742"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=550742"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/550742\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=550742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=550742"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=550742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}