{"id":1108,"date":"2023-03-12T11:45:07","date_gmt":"2023-03-12T03:45:07","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1108"},"modified":"2023-04-29T11:24:07","modified_gmt":"2023-04-29T03:24:07","slug":"elasticsearch-7-learning-advanced-search","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/elasticsearch-7-learning-advanced-search\/","title":{"rendered":"ElasticSearch 7 \u5b66\u4e60\uff0813\uff09\u9ad8\u7ea7\u641c\u7d22"},"content":{"rendered":"<h2>\u7d22\u5f15\u522b\u540d\u7684\u4f7f\u7528<\/h2>\n<p>\u5728\u5f00\u53d1\u4e2d\uff0c\u968f\u7740\u4e1a\u52a1\u9700\u6c42\u7684\u8fed\u4ee3\uff0c\u8f83\u8001\u7684\u4e1a\u52a1\u903b\u8f91\u5c31\u8981\u9762\u4e34\u66f4\u65b0\u751a\u81f3\u662f\u91cd\u6784\uff0c\u800c\u5bf9\u4e8ees\u6765\u8bf4\uff0c\u4e3a\u4e86\u9002\u5e94\u65b0\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u53ef\u80fd\u5c31\u8981\u5bf9\u539f\u6709\u7684\u7d22\u5f15\u505a\u4e00\u4e9b\u4fee\u6539\uff0c\u6bd4\u5982\u5bf9\u67d0\u4e9b\u5b57\u6bb5\u505a\u8c03\u6574\uff0c\u751a\u81f3\u662f\u91cd\u5efa\u7d22\u5f15\u3002\u800c\u505a\u8fd9\u4e9b\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u53ef\u80fd\u4f1a\u5bf9\u4e1a\u52a1\u9020\u6210\u5f71\u54cd\uff0c\u751a\u81f3\u662f\u505c\u673a\u8c03\u6574\u7b49\u95ee\u9898\u3002\u7531\u6b64\uff0ces\u63d0\u4f9b\u4e86\u7d22\u5f15\u522b\u540d\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002\u7d22\u5f15\u522b\u540d\u5c31\u50cf\u4e00\u4e2a\u5feb\u6377\u65b9\u5f0f\u6216\u662f\u8f6f\u8fde\u63a5\uff0c\u53ef\u4ee5\u6307\u5411\u4e00\u4e2a\u6216\u591a\u4e2a\u7d22\u5f15\uff0c\u4e5f\u53ef\u4ee5\u7ed9\u4efb\u610f\u4e00\u4e2a\u9700\u8981\u7d22\u5f15\u540d\u7684API\u6765\u4f7f\u7528\u3002\u522b\u540d\u7684\u5e94\u7528\u4e3a\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u6781\u5927\u7684\u7075\u6d3b\u6027\u3002<\/p>\n<p><!-- more --><\/p>\n<h3>\u67e5\u8be2\u522b\u540d GET\u8bf7\u6c42<\/h3>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba\/_alias \/\/ \u67e5\u8be2nba\u522b\u540d\nlocalhost:9200\/_aliases  \/\/ \u67e5\u8be2\u6240\u6709\u522b\u540d<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  \/\/ \u8bed\u4e49: \u67e5\u770b\u6240\u6709\u522b\u540d\n    &quot;nba&quot;: {\n        &quot;aliases&quot;: {}\n    },\n    &quot;.kibana_task_manager&quot;: {\n        &quot;aliases&quot;: {}\n    },\n    &quot;.kibana_1&quot;: {\n        &quot;aliases&quot;: {\n            &quot;.kibana&quot;: {}\n        }\n    }\n}<\/code><\/pre>\n<h3>\u65b0\u589e\u522b\u540d POST\u8bf7\u6c42<\/h3>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/_aliases<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  \/\/ \u8bed\u4e49: nba \u65b0\u5efa\u522b\u540dnba_v1.0\n  &quot;actions&quot;: [\n    {\n      &quot;add&quot;: {\n        &quot;index&quot;: &quot;nba&quot;,\n        &quot;alias&quot;: &quot;nba_v1.0&quot;\n      }\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;acknowledged&quot;: true\n}<\/code><\/pre>\n<h3>\u5220\u9664\u522b\u540d POST\u8bf7\u6c42<\/h3>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/_aliases<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  \/\/ \u8bed\u4e49: \u5220\u9664nba\u7684nba_v1.0\u522b\u540d\n  &quot;actions&quot;: [\n    {\n      &quot;remove&quot;: {\n        &quot;index&quot;: &quot;nba&quot;,\n        &quot;alias&quot;: &quot;nba_v1.0&quot;\n      }\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;acknowledged&quot;: true\n}<\/code><\/pre>\n<h3>\u91cd\u547d\u540d\u522b\u540d POST\u8bf7\u6c42<\/h3>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/_aliases<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  \/\/ \u5148\u5220\u9664nba_v1.0 \u522b\u540d \u5728\u65b0\u589e nba_v2.0\u522b\u540d\uff0c\u5373\u662f\u91cd\u547d\u540d\n  &quot;actions&quot;: [\n    {\n      &quot;remove&quot;: {\n        &quot;index&quot;: &quot;nba&quot;,\n        &quot;alias&quot;: &quot;nba_v1.0&quot;\n      }\n    },\n    {\n      &quot;add&quot;: {\n        &quot;index&quot;: &quot;nba&quot;,\n        &quot;alias&quot;: &quot;nba_v2.0&quot;\n      }\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;acknowledged&quot;: true\n}<\/code><\/pre>\n<h3>\u901a\u8fc7\u522b\u540d\u83b7\u53d6\u7d22\u5f15 GET\u8bf7\u6c42<\/h3>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_v2.0<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;nba&quot;: {\n        &quot;aliases&quot;: {\n            &quot;nba_v2.0&quot;: {}\n        },\n        &quot;mappings&quot;: {\n            &quot;properties&quot;: {\n                &quot;age&quot;: {\n                    &quot;type&quot;: &quot;integer&quot;\n                },\n                &quot;birthDay&quot;: {\n                    &quot;type&quot;: &quot;date&quot;\n                },\n                &quot;birthDayStr&quot;: {\n                    &quot;type&quot;: &quot;keyword&quot;\n                },\n                &quot;code&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;country&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;countryEn&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;displayAffiliation&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;displayName&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;displayNameEn&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;draft&quot;: {\n                    &quot;type&quot;: &quot;long&quot;\n                },\n                &quot;heightValue&quot;: {\n                    &quot;type&quot;: &quot;float&quot;\n                },\n                &quot;jerseyNo&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;playYear&quot;: {\n                    &quot;type&quot;: &quot;long&quot;\n                },\n                &quot;playerId&quot;: {\n                    &quot;type&quot;: &quot;keyword&quot;\n                },\n                &quot;position&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;schoolType&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;teamCity&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;teamCityEn&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                },\n                &quot;teamConference&quot;: {\n                    &quot;type&quot;: &quot;keyword&quot;\n                },\n                &quot;teamConferenceEn&quot;: {\n                    &quot;type&quot;: &quot;keyword&quot;\n                },\n                &quot;teamName&quot;: {\n                    &quot;type&quot;: &quot;keyword&quot;\n                },\n                &quot;teamNameEn&quot;: {\n                    &quot;type&quot;: &quot;keyword&quot;\n                },\n                &quot;weight&quot;: {\n                    &quot;type&quot;: &quot;text&quot;\n                }\n            }\n        },\n        &quot;settings&quot;: {\n            &quot;index&quot;: {\n                &quot;creation_date&quot;: &quot;1573300240575&quot;,\n                &quot;number_of_shards&quot;: &quot;1&quot;,\n                &quot;number_of_replicas&quot;: &quot;1&quot;,\n                &quot;uuid&quot;: &quot;X7FLu-8sRcijAYKUkgBZQQ&quot;,\n                &quot;version&quot;: {\n                    &quot;created&quot;: &quot;7020199&quot;\n                },\n                &quot;provided_name&quot;: &quot;nba&quot;\n            }\n        }\n    }\n}<\/code><\/pre>\n<h3>\u901a\u8fc7\u522b\u540d\u5199\u7d22\u5f15 POST\u8bf7\u6c42<\/h3>\n<p>\u5f53\u522b\u540d\u6307\u5b9a\u4e86\u4e00\u4e2a\u7d22\u5f15\uff0c\u5219\u53ef\u4ee5\u505a\u5199\u7684\u64cd\u4f5c<\/p>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_v2.0\/_doc\/566<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    \/\/ \u8bed\u4e49: \u901a\u8fc7\u522b\u540dnba_v2.0 \u4fee\u6539id\u4e3a566\u7684\u7403\u5458\n    &quot;countryEn&quot;: &quot;Croatia&quot;,\n    &quot;teamName&quot;: &quot;\u5feb\u8239&quot;,\n    &quot;birthDay&quot;: 858661200000,\n    &quot;country&quot;: &quot;\u514b\u7f57\u5730\u4e9a&quot;,\n    &quot;teamCityEn&quot;: &quot;LA&quot;,\n    &quot;code&quot;: &quot;ivica_zubac&quot;,\n    &quot;displayAffiliation&quot;: &quot;Croatia&quot;,\n    &quot;displayName&quot;: &quot;\u4f0a\u7ef4\u5bdf \u7956\u5df4\u8328\u54e5\u54e5&quot;, \/\/&quot;\u4f0a\u7ef4\u5bdf \u7956\u5df4\u8328&quot;\u4fee\u6539\u4e3a&quot;\u4f0a\u7ef4\u5bdf \u7956\u5df4\u8328\u54e5\u54e5&quot;\n    &quot;schoolType&quot;: &quot;&quot;,\n    &quot;teamConference&quot;: &quot;\u897f\u90e8&quot;,\n    &quot;teamConferenceEn&quot;: &quot;Western&quot;,\n    &quot;weight&quot;: &quot;108.9 \u516c\u65a4&quot;,\n    &quot;teamCity&quot;: &quot;\u6d1b\u6749\u77f6&quot;,\n    &quot;playYear&quot;: 3,\n    &quot;jerseyNo&quot;: &quot;40&quot;,\n    &quot;teamNameEn&quot;: &quot;Clippers&quot;,\n    &quot;draft&quot;: 2016,\n    &quot;displayNameEn&quot;: &quot;Ivica Zubac&quot;,\n    &quot;heightValue&quot;: 2.16,\n    &quot;birthDayStr&quot;: &quot;1997-03-18&quot;,\n    &quot;position&quot;: &quot;\u4e2d\u950b&quot;,\n    &quot;age&quot;: 22,\n    &quot;playerId&quot;: &quot;1627826&quot;\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;_index&quot;: &quot;nba&quot;,\n    &quot;_type&quot;: &quot;_doc&quot;,\n    &quot;_id&quot;: &quot;566&quot;,\n    &quot;_version&quot;: 2,\n    &quot;result&quot;: &quot;updated&quot;,\n    &quot;_shards&quot;: {\n        &quot;total&quot;: 2,\n        &quot;successful&quot;: 1,\n        &quot;failed&quot;: 0\n    },\n    &quot;_seq_no&quot;: 566,\n    &quot;_primary_term&quot;: 1\n}<\/code><\/pre>\n<h2>\u5982\u4f55\u91cd\u5efa\u7d22\u5f15<\/h2>\n<p>Elasticsearch\u662f\u4e00\u4e2a\u5b9e\u65f6\u7684\u5206\u5e03\u5f0f\u641c\u7d22\u5f15\u64ce\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u641c\u7d22\u670d\u52a1\uff0c\u5f53\u6211\u4eec\u51b3\u5b9a\u5b58\u50a8\u67d0\u79cd\u6570\u636e\u65f6\uff0c\u5728\u521b\u5efa\u7d22\u5f15\u7684\u65f6\u5019\u9700\u8981\u5c06\u6570\u636e\u7ed3\u6784\u5b8c\u6574\u786e\u5b9a\u4e0b\u6765\uff0c\u4e8e\u6b64\u540c\u65f6\u7d22\u5f15\u7684\u8bbe\u5b9a\u548c\u5f88\u591a\u56fa\u5b9a\u914d\u7f6e\u5c06\u4e0d\u80fd\u6539\u53d8\u3002\u5f53\u9700\u8981\u6539\u53d8\u6570\u636e\u7ed3\u6784\u65f6\uff0c\u5c31\u9700\u8981\u91cd\u65b0\u5efa\u7acb\u7d22\u5f15\uff0c\u4e3a\u6b64\uff0cElastic\u56e2\u961f\u63d0\u4f9b\u4e86\u5f88\u591a\u8f85\u52a9\u5de5\u5177\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u8fdb\u884c\u91cd\u5efa\u7d22\u5f15\u3002\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>nba\u53d6\u4e00\u4e2a\u522b\u540dnba_latest, nba_latest\u4f5c\u4e3a\u5bf9\u5916\u4f7f\u7528<\/li>\n<\/ol>\n<ul>\n<li>POST \u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/_aliases<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;actions&quot;: [\n    {\n      &quot;add&quot;: {\n        &quot;index&quot;: &quot;nba&quot;,\n        &quot;alias&quot;: &quot;nba_latest&quot;\n      }\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;acknowledged&quot; : true\n}<\/code><\/pre>\n<ol start=\"2\">\n<li>\u65b0\u589e\u4e00\u4e2a\u7d22\u5f15nba_20220101\uff0c\u7ed3\u6784\u590d\u5236\u4e8enba\u7d22\u5f15\uff0c\u6839\u636e\u4e1a\u52a1\u8981\u6c42\u4fee\u6539\u5b57\u6bb5<\/li>\n<\/ol>\n<ul>\n<li>PUT \u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_20220101<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;mappings&quot;: {\n        &quot;properties&quot;: {\n            &quot;age&quot;: {\n                &quot;type&quot;: &quot;integer&quot;\n            },\n            &quot;birthDay&quot;: {\n                &quot;type&quot;: &quot;date&quot;\n            },\n            &quot;birthDayStr&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;code&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;country&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;countryEn&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;displayAffiliation&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;displayName&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;displayNameEn&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;draft&quot;: {\n                &quot;type&quot;: &quot;long&quot;\n            },\n            &quot;heightValue&quot;: {\n                &quot;type&quot;: &quot;float&quot;\n            },\n            &quot;jerseyNo&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;playYear&quot;: {\n                &quot;type&quot;: &quot;long&quot;\n            },\n            &quot;playerId&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;position&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;schoolType&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;teamCity&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;teamCityEn&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            },\n            &quot;teamConference&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;teamConferenceEn&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;teamName&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;teamNameEn&quot;: {\n                &quot;type&quot;: &quot;keyword&quot;\n            },\n            &quot;weight&quot;: {\n                &quot;type&quot;: &quot;text&quot;\n            }\n        }\n    }\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;acknowledged&quot;: true,\n    &quot;shards_acknowledged&quot;: true,\n    &quot;index&quot;: &quot;nba_20220101&quot;\n}<\/code><\/pre>\n<ol start=\"3\">\n<li>\u5c06nba\u6570\u636e\u540c\u6b65\u5230nba_20220101<\/li>\n<\/ol>\n<ul>\n<li>POST \u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/_reindex  \/\/\u540c\u6b65\u8bf7\u6c42 \u7b49\u5f85\u54cd\u5e94\nlocalhost:9200\/_reindex?wait_for_completion=false  \/\/ \u5f02\u6b65\u8bf7\u6c42 \u76f4\u63a5\u8fd4\u56de<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;source&quot;: {\n    &quot;index&quot;: &quot;nba&quot;\n  },\n  &quot;dest&quot;: {\n    &quot;index&quot;: &quot;nba_20220101&quot;\n  }\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;took&quot; : 102,\n  &quot;timed_out&quot; : false,\n  &quot;total&quot; : 566,\n  &quot;updated&quot; : 0,\n  &quot;created&quot; : 566,\n  &quot;deleted&quot; : 0,\n  &quot;batches&quot; : 1,\n  &quot;version_conflicts&quot; : 0,\n  &quot;noops&quot; : 0,\n  &quot;retries&quot; : {\n    &quot;bulk&quot; : 0,\n    &quot;search&quot; : 0\n  },\n  &quot;throttled_millis&quot; : 0,\n  &quot;requests_per_second&quot; : -1.0,\n  &quot;throttled_until_millis&quot; : 0,\n  &quot;failures&quot; : [ ]\n}<\/code><\/pre>\n<ol start=\"4\">\n<li>\u7ed9nba_20220101\u6dfb\u52a0\u522b\u540dnba_latest\uff0c\u5220\u9664nba\u522b\u540dnba_latest<\/li>\n<\/ol>\n<ul>\n<li>POST\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/_aliases<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;actions&quot;: [\n    {\n      &quot;add&quot;: {\n        &quot;index&quot;: &quot;nba_20220101&quot;,\n        &quot;alias&quot;: &quot;nba_latest&quot;\n      }\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;acknowledged&quot; : true\n}\n<\/code><\/pre>\n<ol start=\"5\">\n<li>\u5220\u9664nba\u7d22\u5f15<\/li>\n<\/ol>\n<ul>\n<li>DELETE\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;acknowledged&quot; : true\n}<\/code><\/pre>\n<h2>refresh\u64cd\u4f5c<\/h2>\n<p>\u7406\u60f3\u7684\u641c\u7d22<\/p>\n<ol>\n<li>\n<p>\u65b0\u7684\u6570\u636e\u4e00\u6dfb\u52a0\u5230\u7d22\u5f15\u4e2d\u7acb\u9a6c\u5c31\u80fd\u641c\u7d22\u5230\uff0c\u4f46\u662f\u771f\u5b9e\u60c5\u51b5\u4e0d\u662f\u8fd9\u6837\u7684<\/p>\n<\/li>\n<li>\n<p>\u6211\u4eec\u4f7f\u7528\u94fe\u5f0f\u547d\u4ee4\u8bf7\u6c42\uff0c\u5148\u6dfb\u52a0\u4e00\u4e2a\u6587\u6863\uff0c\u518d\u7acb\u523b\u641c\u7d22<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"language-java\">curl -X PUT localhost:9200\/star\/_doc\/888 -H &#039;Content-Type: application\/json&#039; -d &#039;{ &quot;displayName&quot;: &quot;\u8521\u5f90\u5764&quot; }&#039;\n\ncurl -X GET localhost:9200\/star\/_doc\/_search?pretty<\/code><\/pre>\n<ol start=\"3\">\n<li>\u5f3a\u5236\u5237\u65b0<\/li>\n<\/ol>\n<pre><code class=\"language-java\">curl -X PUT localhost:9200\/star\/_doc\/666?refresh -H &#039;Content-Type: application\/json&#039; -d &#039;{ &quot;displayName&quot;: &quot;\u6768\u8d85\u8d8a&quot; }&#039;\n\ncurl -X GET localhost:9200\/star\/_doc\/_search?pretty<\/code><\/pre>\n<ol start=\"4\">\n<li>\u4fee\u6539\u9ed8\u8ba4\u66f4\u65b0\u65f6\u95f4(\u9ed8\u8ba4\u65f6\u95f4\u662f1s)<\/li>\n<\/ol>\n<ul>\n<li>PUT \u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/star\/_settings<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;index&quot;:{\n    &quot;refresh_interval&quot;: &quot;5s&quot;\n  }\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;acknowledged&quot; : true\n}<\/code><\/pre>\n<ol start=\"5\">\n<li>\u5c06refresh\u5173\u95ed<\/li>\n<\/ol>\n<ul>\n<li>PUT \u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/star\/_settings<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;index&quot;:{\n    &quot;refresh_interval&quot;: &quot;-1&quot;\n  }\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;acknowledged&quot; : true\n}<\/code><\/pre>\n<h2>\u9ad8\u4eae\u67e5\u8be2<\/h2>\n<p>\u5982\u679c\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u4e2d\u5f88\u591a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c\uff0c\u90a3\u600e\u4e48\u80fd\u4e00\u773c\u5c31\u80fd\u770b\u5230\u6211\u4eec\u60f3\u8981\u7684\u90a3\u4e2a\u7ed3\u679c\u5462\uff1f\u6bd4\u5982\uff0c\u6211\u4eec\u641c\u7d22\u59da\u660e\uff0c\u5728\u7ed3\u679c\u96c6\u4e2d\uff0c\u5c06\u6240\u6709\u59da\u660e\u9ad8\u4eae\u663e\u793a\uff1f<\/p>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_latest\/_search<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  \/\/ \u8bed\u4e49: \u67e5\u627eNBA james\u7403\u5458\uff0c\u5bf9james\u505a\u9ad8\u4eae\u663e\u793a\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;displayNameEn&quot;: &quot;james&quot;\n    }\n  },\n  &quot;highlight&quot;: { \/\/ \u9ad8\u4eae\u5173\u952e\u5b57\n    &quot;fields&quot;: { \/\/ \u5bf9displayNameEn\u505a\u9ad8\u4eae\n      &quot;displayNameEn&quot;: {}\n    }\n  },\n  &quot;size&quot;: 2\n}\n\n\/\/ \u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6807\u7b7e\n{\n  &quot;query&quot;: {\n    &quot;match&quot;: {\n      &quot;displayNameEn&quot;: &quot;james&quot;\n    }\n  },\n  &quot;highlight&quot;: {\n    &quot;fields&quot;: {\n      &quot;displayNameEn&quot;: {\n        \/\/ \u5b9a\u4e49\u9ad8\u4eae\u6807\u7b7e\u4e3a h1\n        &quot;pre_tags&quot;: [&quot;&lt;h1&gt;&quot;],\n        &quot;post_tags&quot;: [&quot;&lt;\/h1&gt;&quot;]\n\n      }\n    }\n  },\n  &quot;size&quot;: 2\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;took&quot; : 2,\n  &quot;timed_out&quot; : false,\n  &quot;_shards&quot; : {\n    &quot;total&quot; : 1,\n    &quot;successful&quot; : 1,\n    &quot;skipped&quot; : 0,\n    &quot;failed&quot; : 0\n  },\n  &quot;hits&quot; : {\n    &quot;total&quot; : {\n      &quot;value&quot; : 5,\n      &quot;relation&quot; : &quot;eq&quot;\n    },\n    &quot;max_score&quot; : 4.699642,\n    &quot;hits&quot; : [\n      {\n        &quot;_index&quot; : &quot;nba_20220101&quot;,\n        &quot;_type&quot; : &quot;_doc&quot;,\n        &quot;_id&quot; : &quot;214&quot;,\n        &quot;_score&quot; : 4.699642,\n        &quot;_source&quot; : {\n          &quot;countryEn&quot; : &quot;United States&quot;,\n          &quot;teamName&quot; : &quot;\u706b\u7bad&quot;,\n          &quot;birthDay&quot; : 620107200000,\n          &quot;country&quot; : &quot;\u7f8e\u56fd&quot;,\n          &quot;teamCityEn&quot; : &quot;Houston&quot;,\n          &quot;code&quot; : &quot;james_harden&quot;,\n          &quot;displayAffiliation&quot; : &quot;Arizona State\/United States&quot;,\n          &quot;displayName&quot; : &quot;\u8a79\u59c6\u65af \u54c8\u767b&quot;,\n          &quot;schoolType&quot; : &quot;College&quot;,\n          &quot;teamConference&quot; : &quot;\u897f\u90e8&quot;,\n          &quot;teamConferenceEn&quot; : &quot;Western&quot;,\n          &quot;weight&quot; : &quot;99.8 \u516c\u65a4&quot;,\n          &quot;teamCity&quot; : &quot;\u4f11\u65af\u987f&quot;,\n          &quot;playYear&quot; : 10,\n          &quot;jerseyNo&quot; : &quot;13&quot;,\n          &quot;teamNameEn&quot; : &quot;Rockets&quot;,\n          &quot;draft&quot; : 2009,\n          &quot;displayNameEn&quot; : &quot;James Harden&quot;,\n          &quot;heightValue&quot; : 1.96,\n          &quot;birthDayStr&quot; : &quot;1989-08-26&quot;,\n          &quot;position&quot; : &quot;\u540e\u536b&quot;,\n          &quot;age&quot; : 30,\n          &quot;playerId&quot; : &quot;201935&quot;\n        },\n        &quot;highlight&quot; : {\n          \/\/ &quot;&lt;em&gt; \u5305\u88f9\u8d77\u6765\u662f \u9ad8\u4eae\u7684\u610f\u601d\n          &quot;displayNameEn&quot; : [\n            &quot;&lt;em&gt;James&lt;\/em&gt; Harden&quot;\n          ]\n        }\n      },\n      {\n        &quot;_index&quot; : &quot;nba_20220101&quot;,\n        &quot;_type&quot; : &quot;_doc&quot;,\n        &quot;_id&quot; : &quot;266&quot;,\n        &quot;_score&quot; : 4.699642,\n        &quot;_source&quot; : {\n          &quot;countryEn&quot; : &quot;United States&quot;,\n          &quot;teamName&quot; : &quot;\u56fd\u738b&quot;,\n          &quot;birthDay&quot; : 854082000000,\n          &quot;country&quot; : &quot;\u7f8e\u56fd&quot;,\n          &quot;teamCityEn&quot; : &quot;Sacramento&quot;,\n          &quot;code&quot; : &quot;justin_james&quot;,\n          &quot;displayAffiliation&quot; : &quot;United States&quot;,\n          &quot;displayName&quot; : &quot;\u8d3e\u65af\u6c40 \u8a79\u59c6\u65af&quot;,\n          &quot;schoolType&quot; : &quot;College&quot;,\n          &quot;teamConference&quot; : &quot;\u897f\u90e8&quot;,\n          &quot;teamConferenceEn&quot; : &quot;Western&quot;,\n          &quot;weight&quot; : &quot;86.2 \u516c\u65a4&quot;,\n          &quot;teamCity&quot; : &quot;\u8428\u514b\u62c9\u95e8\u6258&quot;,\n          &quot;playYear&quot; : 0,\n          &quot;jerseyNo&quot; : &quot;&quot;,\n          &quot;teamNameEn&quot; : &quot;Kings&quot;,\n          &quot;draft&quot; : 2019,\n          &quot;displayNameEn&quot; : &quot;Justin James&quot;,\n          &quot;heightValue&quot; : 2.01,\n          &quot;birthDayStr&quot; : &quot;1997-01-24&quot;,\n          &quot;position&quot; : &quot;\u540e\u536b-\u524d\u950b&quot;,\n          &quot;age&quot; : 22,\n          &quot;playerId&quot; : &quot;1629713&quot;\n        },\n        &quot;highlight&quot; : {\n          \/\/ &quot;&lt;em&gt; \u5305\u88f9\u8d77\u6765\u662f \u9ad8\u4eae\u7684\u610f\u601d\n          &quot;displayNameEn&quot; : [\n            &quot;Justin &lt;em&gt;James&lt;\/em&gt;&quot;\n          ]\n        }\n      }\n    ]\n  }\n}<\/code><\/pre>\n<h2>\u67e5\u8be2\u5efa\u8bae<\/h2>\n<ul>\n<li>\u67e5\u8be2\u5efa\u8bae\u662f\u4ec0\u4e48<\/li>\n<\/ul>\n<p>\u67e5\u8be2\u5efa\u8bae\uff0c\u662f\u4e3a\u4e86\u7ed9\u7528\u6237\u63d0\u4f9b\u66f4\u597d\u7684\u641c\u7d22\u4f53\u9a8c\u3002\u5305\u62ec\uff1a\u8bcd\u6761\u68c0\u67e5\uff0c\u81ea\u52a8\u8865\u5168<\/p>\n<ul>\n<li><code>Suggester<\/code><\/li>\n<\/ul>\n<p>\uff081\uff09<code>Term suggester<\/code><br \/>\n\uff082\uff09<code>Phrase suggester<\/code><br \/>\n\uff083\uff09<code>Completion suggester<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th>text<\/th>\n<th>\u6307\u5b9a\u641c\u7d22\u6587\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>field<\/code><\/td>\n<td>\u83b7\u53d6\u5efa\u8bae\u8bcd\u7684\u641c\u7d22\u5b57\u6bb5<\/td>\n<\/tr>\n<tr>\n<td><code>analyzer<\/code><\/td>\n<td>\u6307\u5b9a\u5206\u8bcd\u5668<\/td>\n<\/tr>\n<tr>\n<td><code>size<\/code><\/td>\n<td>\u6bcf\u4e2a\u8bcd\u8fd4\u56de\u7684\u6700\u5927\u5efa\u8bae\u8bcd\u6570<\/td>\n<\/tr>\n<tr>\n<td><code>sort<\/code><\/td>\n<td>\u5982\u4f55\u5bf9\u5efa\u8bae\u8bcd\u8fdb\u884c\u6392\u5e8f\uff0c\u53ef\u7528\u9009\u9879\uff1a<br \/>score:\u5148\u6309\u8bc4\u5206\u6392\u5e8f\u3001\u518d\u6309\u6587\u6863\u9891\u7387\u3001term\u987a\u5e8f\u6392<br \/>frequency:\u5148\u6309\u6587\u6863\u9891\u7387\u6392\uff0c\u518d\u6309\u8bc4\u5206\u3001term\u987a\u5e8f\u6392<\/td>\n<\/tr>\n<tr>\n<td><code>suggest_mode<\/code><\/td>\n<td>\u5efa\u8bae\u6a21\u5f0f\uff0c\u63a7\u5236\u63d0\u4f9b\u5efa\u8bae\u8bcd\u7684\u65b9\u5f0f\uff1a<br \/>missing:\u4ec5\u5728\u641c\u7d22\u7684\u8bcd\u9879\u5728\u7d22\u5f15\u4e2d\u4e0d\u5b58\u5728\u65f6\u624d\u63d0\u4f9b\u5efa\u8bae\u8bcd\uff0c\u9ed8\u8ba4\u503c<br \/>popular:\u4ec5\u5efa\u8bae\u6587\u6863\u9891\u7387\u6bd4\u641c\u7d22\u8bcd\u9879\u9ad8\u7684\u8bcd<br \/>always\uff1a\u603b\u662f\u63d0\u4f9b\u5339\u914d\u7684\u5efa\u8bae\u8bcd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>term suggester<\/h3>\n<p><code>term<\/code>\u8bcd\u6761\u5efa\u8bae\u5668 \uff0c\u5bf9\u7ed9\u8f93\u5165\u7684\u6587\u672c\u8fdb\u884c\u5206\u8bcd\uff0c\u4e3a\u6bcf\u4e2a\u5206\u8bcd\u63d0\u4f9b\u8bcd\u9879\u5efa\u8bae<\/p>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_latest\/_search<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;suggest&quot;: {\n    &quot;my-suggest&quot;: {\n      &quot;text&quot;: &quot;jamse&quot;, \/\/\u7528\u6237\u53ef\u80fd\u8f93\u5165\u9519\u8bef jsmes\u5199\u6210jamse\n      &quot;term&quot;: {\n        &quot;suggest_mode&quot;: &quot;missing&quot;,\n        &quot;field&quot;: &quot;displayNameEn&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;took&quot; : 3,\n  &quot;timed_out&quot; : false,\n  &quot;_shards&quot; : {\n    &quot;total&quot; : 1,\n    &quot;successful&quot; : 1,\n    &quot;skipped&quot; : 0,\n    &quot;failed&quot; : 0\n  },\n  &quot;hits&quot; : {\n    &quot;total&quot; : {\n      &quot;value&quot; : 0,\n      &quot;relation&quot; : &quot;eq&quot;\n    },\n    &quot;max_score&quot; : null,\n    &quot;hits&quot; : [ ]\n  },\n  &quot;suggest&quot; : {\n    &quot;my-suggest&quot; : [\n      {\n        &quot;text&quot; : &quot;jamse&quot;,\n        &quot;offset&quot; : 0,\n        &quot;length&quot; : 5,\n        &quot;options&quot; : [\n          {\n            &quot;text&quot; : &quot;james&quot;,\n            &quot;score&quot; : 0.8,\n            &quot;freq&quot; : 5\n          },\n          {\n            &quot;text&quot; : &quot;jamal&quot;,\n            &quot;score&quot; : 0.6,\n            &quot;freq&quot; : 2\n          },\n          {\n            &quot;text&quot; : &quot;jake&quot;,\n            &quot;score&quot; : 0.5,\n            &quot;freq&quot; : 1\n          },\n          {\n            &quot;text&quot; : &quot;jose&quot;,\n            &quot;score&quot; : 0.5,\n            &quot;freq&quot; : 1\n          }\n        ]\n      },\n      {\n        &quot;text&quot; : &quot;hardne&quot;,\n        &quot;offset&quot; : 6,\n        &quot;length&quot; : 6,\n        &quot;options&quot; : [\n          {\n            &quot;text&quot; : &quot;harden&quot;,\n            &quot;score&quot; : 0.8333333,\n            &quot;freq&quot; : 1\n          }\n        ]\n      }\n    ]\n  }\n}<\/code><\/pre>\n<h3>phrase suggester<\/h3>\n<p><code>phrase<\/code>\u77ed\u8bed\u5efa\u8bae\uff0c\u5728<code>term<\/code>\u7684\u57fa\u7840\u4e0a\uff0c\u4f1a\u8003\u91cf\u591a\u4e2a<code>term<\/code>\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u6bd4\u5982\u662f\u5426\u540c\u65f6\u51fa\u73b0\u5728\u7d22\u5f15\u7684\u539f\u6587\u91cc\uff0c\u76f8\u90bb\u7a0b\u5ea6\uff0c\u4ee5\u53ca\u8bcd\u9891\u7b49<\/p>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_latest\/_search<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;suggest&quot;: {\n    &quot;my-suggest&quot;: {\n      &quot;text&quot;: &quot;jamse hardne&quot;,\n      &quot;phrase&quot;: { \/\/ \u8bcd\u7ec4 \u5bf9\u5355\u8bcd\u8fdb\u884c\u8054\u7cfb\n        &quot;field&quot;: &quot;displayNameEn&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<ul>\n<li>\u54cd\u5e94<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;took&quot; : 26,\n  &quot;timed_out&quot; : false,\n  &quot;_shards&quot; : {\n    &quot;total&quot; : 1,\n    &quot;successful&quot; : 1,\n    &quot;skipped&quot; : 0,\n    &quot;failed&quot; : 0\n  },\n  &quot;hits&quot; : {\n    &quot;total&quot; : {\n      &quot;value&quot; : 0,\n      &quot;relation&quot; : &quot;eq&quot;\n    },\n    &quot;max_score&quot; : null,\n    &quot;hits&quot; : [ ]\n  },\n  &quot;suggest&quot; : {\n    &quot;my-suggest&quot; : [\n      {\n        &quot;text&quot; : &quot;jamse hardne&quot;,\n        &quot;offset&quot; : 0,\n        &quot;length&quot; : 12,\n        &quot;options&quot; : [\n          {\n            &quot;text&quot; : &quot;james hardne&quot;,\n            &quot;score&quot; : 0.0025682184\n          },\n          {\n            &quot;text&quot; : &quot;jamal hardne&quot;,\n            &quot;score&quot; : 0.0016773979\n          },\n          {\n            &quot;text&quot; : &quot;jamse harden&quot;,\n            &quot;score&quot; : 0.0016222595\n          },\n          {\n            &quot;text&quot; : &quot;jake hardne&quot;,\n            &quot;score&quot; : 0.001299489\n          },\n          {\n            &quot;text&quot; : &quot;jose hardne&quot;,\n            &quot;score&quot; : 0.001299489\n          }\n        ]\n      }\n    ]\n  }\n}<\/code><\/pre>\n<h3>completion suggester<\/h3>\n<p><code>completion<\/code>\u5b8c\u6210\u5efa\u8bae<\/p>\n<ul>\n<li>\u8bf7\u6c42<\/li>\n<\/ul>\n<pre><code class=\"language-java\">localhost:9200\/nba_latest\/_search<\/code><\/pre>\n<ul>\n<li>\u8bf7\u6c42\u4f53<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;suggest&quot;: {\n    &quot;my-suggest&quot;: {\n      &quot;text&quot;: &quot;Miam&quot;,\n      &quot;completion&quot;:{\n        &quot;field&quot;: &quot;teamCityEn&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7d22\u5f15\u522b\u540d\u7684\u4f7f\u7528 \u5728\u5f00\u53d1\u4e2d\uff0c\u968f\u7740\u4e1a\u52a1\u9700\u6c42\u7684\u8fed\u4ee3\uff0c\u8f83\u8001\u7684\u4e1a\u52a1\u903b\u8f91\u5c31\u8981\u9762\u4e34\u66f4\u65b0\u751a\u81f3\u662f\u91cd\u6784\uff0c\u800c\u5bf9\u4e8ees\u6765\u8bf4\uff0c\u4e3a\u4e86\u9002\u5e94\u65b0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[301],"tags":[],"class_list":["post-1108","post","type-post","status-publish","format-standard","hentry","category-elasticsearch"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1108"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1108\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}