{"id":361308,"date":"2021-02-21T12:07:11","date_gmt":"2021-02-21T04:07:11","guid":{"rendered":"http:\/\/4563.org\/?p=361308"},"modified":"2021-02-21T12:07:11","modified_gmt":"2021-02-21T04:07:11","slug":"es-%e7%94%a8-php-%e9%94%99%e8%af%af%e7%9a%84%e5%88%9b%e5%bb%ba%e4%ba%86%e7%b4%a2%e5%bc%95%ef%bc%8c%e5%b1%85%e7%84%b6%e6%b2%a1%e6%8a%a5%e9%94%99%ef%bc%8c%e7%9b%ae%e5%89%8d%e5%a4%84%e4%ba%8e%e7%94%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=361308","title":{"rendered":"ES \u7528 PHP \u9519\u8bef\u7684\u521b\u5efa\u4e86\u7d22\u5f15\uff0c\u5c45\u7136\u6ca1\u62a5\u9519\uff0c\u76ee\u524d\u5904\u4e8e\u751f\u4ea7\u73af\u5883\u4e2d\u600e\u4e48\u4fee\u590d\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  ES \u7528 PHP \u9519\u8bef\u7684\u521b\u5efa\u4e86\u7d22\u5f15\uff0c\u5c45\u7136\u6ca1\u62a5\u9519\uff0c\u76ee\u524d\u5904\u4e8e\u751f\u4ea7\u73af\u5883\u4e2d\u600e\u4e48\u4fee\u590d\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kisshere <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u76ee\u524d\u6211\u7528 php \u521b\u5efa\u4e00\u4e2a index\uff0cES \u7248\u672c\uff1a6.7.2\uff1a<\/p>\n<pre><code>&lt;?php $client = ClientBuilder::create()-&gt;build(); $params = [     'index' =&gt; 'MyIndex',     'body' =&gt; [         'settings' =&gt; [             'number_of_shards' =&gt; 2,             'number_of_replicas' =&gt; 0         ],         'MyType' =&gt; [             'properties' =&gt; [                 'title' =&gt; [                     'type'=&gt;'text',                     'analyzer'=&gt;'thai',                 ],                 'createTime' =&gt; [                     'type'=&gt;'integer',                     'index' =&gt; false                 ],                 'uid' =&gt; [                     'type'=&gt;'integer'                 ]             ]         ]     ] ]; $client-&gt;indices()-&gt;create($params); ?&gt; <\/code><\/pre>\n<p>\u76ee\u524d\u51e0\u4e4e query \u4e0d\u51fa\u6765\u4efb\u4f55\u7ed3\u679c\uff0c\u4e00\u67e5 ES \u5b98\u7f51\uff0c\u53d1\u73b0\u5c45\u7136\u5199\u9519\u4e86\uff0c\u5c11\u52a0\u4e86\u4e00\u4e2a mapping\uff0c\u6b63\u786e\u7684\u5e94\u8be5\u662f\uff1a<\/p>\n<pre><code>&lt;?php $client = ClientBuilder::create()-&gt;build(); $params = [     'index' =&gt; 'MyIndex',     'body' =&gt; [         'settings' =&gt; [             'number_of_shards' =&gt; 2,             'number_of_replicas' =&gt; 0         ],         'mappings' =&gt; [             'MyType' =&gt; [                 '_source' =&gt; [                     'enabled' =&gt; true                 ],                 'properties' =&gt; [                     'title' =&gt; [                         'type'=&gt;'text',                         'analyzer'=&gt;'thai',                     ],                     'createTime' =&gt; [                         'type'=&gt;'integer',                         'index' =&gt; false                     ],                     'uid' =&gt; [                         'type'=&gt;'integer'                     ]                 ]             ]         ]      ] ]; $client-&gt;indices()-&gt;create($params); ?&gt; <\/code><\/pre>\n<p>\u90a3\u4e48\u95ee\u9898\u6765\u4e86\uff1a<\/p>\n<ol>\n<li>\u4e3a\u4ec0\u4e48\u5c11\u4e86\u4e00\u4e2a mappings\uff0cES \u5c45\u7136\u4e0d\u62a5\u9519\uff1f\uff1f\uff1f\u90a3\u4e48\u5b83\u9ed8\u8ba4\u662f\u600e\u6837\u5904\u7406\u8be5\u4ee3\u7801\u7684\uff0c\u4ee5\u600e\u6837\u7684 analyzer \u548c tokenizer \u6765\u521b\u5efa\u7684 index \uff1f\u76ee\u524d\u53ea\u80fd\u641c\u7d22\u51fa\u6709\u7a7a\u683c\u7684\u7ed3\u679c\uff0c\u6bd4\u5982\uff0c\u6211\u60f3\u641c\u201cABC\u201d\uff0c\u90a3\u4e48\u201cABC DEF WXYZ\u201d\u80fd\u641c\u51fa\u6765\uff0c\u4f46\u201cABCDEFGHIJK\u201d\u5c31\u641c\u4e0d\u51fa\u6765<\/li>\n<li>\u76ee\u524d\u5904\u4e8e\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u90a3\u4e48\u8be5\u5982\u4f55\u8865\u6551\uff1f<\/li>\n<\/ol><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>12<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5415472\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhuzhibin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9996\u5148 create \u7684\u65f6\u5019\u80fd\u5426 catch \u5230\u5f02\u5e38\u5462\uff1f\u751f\u4ea7\u73af\u5883\u4f60\u4eec\u662f\u5982\u4f55\u53d1\u5e03\u4ee5\u53ca\u90e8\u7f72\u7684\u5462\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415473\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dilu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u5199 sql \u7684\u65f6\u5019\uff0c\u6ca1\u6709\u52a0\u7d22\u5f15\uff0cmysql \u4f1a\u62a5\u9519\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415474\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : daxin945 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6700\u7b28\u7684\u65b9\u6cd5 \u518d\u642d\u4e00\u4e2a\u6ca1\u95ee\u9898\u7684 es \u7136\u540e\u627e\u4e2a\u53ef\u4ee5\u7ef4\u62a4\u7684\u65f6\u95f4\u8282\u70b9 \u5012\u4e0b\u6570\u636e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415475\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wakzz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             es \u4e0d\u652f\u6301\u4fee\u6539\u7d22\u5f15\uff0c\u6240\u4ee5\u5efa\u8bae\u65b0\u5efa\u4e00\u4e2a\u7d22\u5f15\uff0c\u7136\u540e\u628a\u65e7\u7d22\u5f15\u6570\u636e\u8fc1\u79fb\u8fc7\u53bb\u540e\uff0c\u518d\u901a\u8fc7\u522b\u540d\u76f4\u63a5\u6307\u5411\u65b0\u7d22\u5f15                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415476\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : faqqcn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             es \u6700\u9a9a\u7684\u5c31\u662f\u521b\u5efa\u540e\uff0c\u6ca1\u6709\u529e\u6cd5\u4fee\u6539\u3002<\/p>\n<p>\u4f60\u5c31\u53ea\u80fd\u65b0\u5efa\u4e00\u4e2a\u7d22\u5f15\uff0c\u628a\u6570\u636e\u5bfc\u8fdb\u53bb\u540e\uff0c\u5220\u6389\u539f\u6765\u7684\uff0c\u518d\u628a\u65b0\u5efa\u7684\u7d22\u5f15\u7ed9\u4e2a alias\uff0c\u6216\u8005\u4fee\u6539\u4ee3\u7801\u4e2d\u8fde\u63a5\u7684\u7d22\u5f15\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415477\" 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>                                                             1.\u4e3a\u5565\u6ca1\u62a5\u9519\uff0c\u4f60\u5e94\u8be5\u76f4\u63a5\u770b es \u91cc\u9762\u5efa\u51fa\u6765\u662f\u5565\u6837\u7684<\/p>\n<p>2.\u548b\u89e3\u51b3\uff0c\u5148\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7d22\u5f15\uff0c\u7136\u540e\u53cc\u5199\u4e24\u4e2a\u7d22\u5f15\uff0c\u518d\u8d77\u4e00\u4e2a\u8fdb\u7a0b\u540c\u6b65\u8001\u6570\u636e\uff0c\u4e24\u8fb9\u6570\u636e\u4e00\u81f4\u4ee5\u540e\u5207\u5230\u65b0\u7d22\u5f15\uff0c\u5220\u9664\u8001\u7d22\u5f15                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415478\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : SjwNo1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             rebuild                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415479\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sss495088732 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0a rebuild \u6b63\u89e3~,\u53ef\u4ee5\u5148\u5199\u597d template(mapping),index name regular \u5c31\u53ef\u4ee5\u4e86 0.0<br \/>index \u4e0d\u5927(\u4e0d\u8fc7\u4ebf)\u7684\u8bdd\u662f\u975e\u5e38\u5feb\u7684<br \/>20 \u5206\u949f\u4ee5\u5185                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415480\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vindurriel <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0a\u751f\u4ea7\u73af\u5883\u4e4b\u524d\u8fd8\u5f97\u5148\u6d4b\u4e00\u6d4b\u7684<br \/>\u521b\u5efa\u65b0\u7684 index \u786e\u8ba4 mapping \u65e0\u8bef\u4e4b\u540e \u7528 reindex \u6216\u8005 clone \u63a5\u53e3\u5bfc\u6570\u636e \u540d\u5b57\u7528 alias \u4fdd\u6301\u4e00\u81f4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415481\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qq1340691923 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3a\u5565\u8981\u7528 es \u5462                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415482\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jackeriss <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7ed9\u7d22\u5f15\u52a0\u4e2a\u522b\u540d\uff0c\u641c\u7d22\u7684\u65f6\u5019\u7528\u522b\u540d\uff0c\u5199\u5165\u7528\u771f\u540d\uff0creindex \u4fee\u6539 mapping\uff0c\u5b8c\u4e86\u4e4b\u540e\u66ff\u6362\u522b\u540d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5415483\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuancoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u6709\u62a5\u9519\u662f\u56e0\u4e3a mapping \u4e0d\u662f\u5fc5\u987b\u7684\uff0ces \u4f1a\u6839\u636e\u4f60\u7684\u503c\u81ea\u52a8\u8bc6\u522b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>ES \u7528 PHP \u9519\u8bef\u7684\u521b\u5efa\u4e86\u7d22\u5f15&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/361308"}],"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=361308"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/361308\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=361308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=361308"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=361308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}