{"id":1388,"date":"2023-03-19T11:06:22","date_gmt":"2023-03-19T03:06:22","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1388"},"modified":"2023-04-28T21:11:41","modified_gmt":"2023-04-28T13:11:41","slug":"termquery-matching-failed-during-elasticsearch-query","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/19\/termquery-matching-failed-during-elasticsearch-query\/","title":{"rendered":"ElasticSearch\u67e5\u8be2\u65f6termQuery\u5339\u914d\u5931\u8d25"},"content":{"rendered":"<p>\u95ee\u9898\uff1aElasticSearch\u67e5\u8be2\u65f6termQuery\u67e5\u8be2\u4e2d\u6587\u5339\u914d\u5931\u8d25<\/p>\n<pre><code class=\"language-java\">NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();\nqueryBuilder.withQuery(QueryBuilders.termQuery(&quot;loglvl&quot;, &quot;ERROR&quot;));<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a\u4f7f\u7528<code>xxx.keyword<\/code><\/p>\n<pre><code class=\"language-java\">NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();\nqueryBuilder.withQuery(QueryBuilders.termQuery(&quot;loglvl.keyword&quot;, &quot;ERROR&quot;));<\/code><\/pre>\n<p>\u6216\u8005\u4f7f\u7528<code>matchQuery<\/code><\/p>\n<pre><code class=\"language-java\">NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();\nqueryBuilder.withQuery(QueryBuilders.matchQuery(&quot;loglvl&quot;, &quot;ERROR&quot;));<\/code><\/pre>\n<p>ElasticSearch\u7684<code>matchQuery<\/code>\u4e0e<code>termQuery<\/code>\u533a\u522b\uff1a<\/p>\n<ul>\n<li><code>matchQuery<\/code>\uff1a\u4f1a\u5c06\u641c\u7d22\u8bcd\u5206\u8bcd\uff0c\u518d\u4e0e\u76ee\u6807\u67e5\u8be2\u5b57\u6bb5\u8fdb\u884c\u5339\u914d\uff0c\u82e5\u5206\u8bcd\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u8bcd\u4e0e\u76ee\u6807\u5b57\u6bb5\u5339\u914d\u4e0a\uff0c\u5219\u53ef\u67e5\u8be2\u5230<\/li>\n<li><code>termQuery<\/code>\uff1a\u4e0d\u4f1a\u5bf9\u641c\u7d22\u8bcd\u8fdb\u884c\u5206\u8bcd\u5904\u7406\uff0c\u800c\u662f\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\u4e0e\u76ee\u6807\u5b57\u6bb5\u8fdb\u884c\u5339\u914d\uff0c\u82e5\u5b8c\u5168\u5339\u914d\uff0c\u5219\u53ef\u67e5\u8be2\u5230<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\uff1aElasticSearch\u67e5\u8be2\u65f6termQuery\u67e5\u8be2\u4e2d\u6587\u5339\u914d\u5931\u8d25 NativeSearchQueryB [&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-1388","post","type-post","status-publish","format-standard","hentry","category-elasticsearch"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1388","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=1388"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1388\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}