You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/04/28 08:19:41 UTC

[skywalking] 01/01: Fix bug about match query.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch alarm-query
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit c5d25a9efbad8657086feee65b962e51666f02da
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Sun Apr 28 16:19:29 2019 +0800

    Fix bug about match query.
---
 CHANGES.md                                          |  1 +
 .../elasticsearch/base/StorageEsInstaller.java      |  2 +-
 .../plugin/elasticsearch/query/AlarmQueryEsDAO.java |  2 +-
 .../plugin/elasticsearch/query/TraceQueryEsDAO.java | 21 ++++++---------------
 4 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index ca36a73..d46e685 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -52,6 +52,7 @@ Significantly cost less CPU in low payload.**
 - Support set separated gRPC/Jetty ip:port for receiver, default still use core settings.
 - Fix JVM receiver bug.
 - Fix wrong dest service in mesh analysis.
+- Fix search doesn't work as expected.
 - Refactor `ScopeDeclaration` annotation.
 - Refactor register lock mechanism.
 - Add SmartSql component for .NET
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
index 156bf43..47a7ad4 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
@@ -120,7 +120,7 @@ public class StorageEsInstaller extends ModelInstaller {
                 JsonObject matchColumn = new JsonObject();
                 matchColumn.addProperty("type", "text");
                 matchColumn.addProperty("analyzer", "oap_analyzer");
-                properties.add(columnDefine.getColumnName().getName(), matchColumn);
+                properties.add(matchCName, matchColumn);
             } else {
                 JsonObject column = new JsonObject();
                 column.addProperty("type", columnTypeEsMapping.transform(columnDefine.getType()));
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java
index 5db788d..3c0a304 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java
@@ -54,7 +54,7 @@ public class AlarmQueryEsDAO extends EsDAO implements IAlarmQueryDAO {
 
         if (!Strings.isNullOrEmpty(keyword)) {
             String matchCName = MatchCNameBuilder.INSTANCE.build(AlarmRecord.ALARM_MESSAGE);
-            boolQueryBuilder.must().add(QueryBuilders.matchQuery(matchCName, keyword));
+            boolQueryBuilder.must().add(QueryBuilders.matchPhraseQuery(matchCName, keyword));
         }
 
         sourceBuilder.query(boolQueryBuilder);
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
index 8a31bf7..600eb4e 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
@@ -20,25 +20,15 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
 
 import com.google.common.base.Strings;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
-import org.apache.skywalking.oap.server.core.query.entity.BasicTrace;
-import org.apache.skywalking.oap.server.core.query.entity.QueryOrder;
-import org.apache.skywalking.oap.server.core.query.entity.Span;
-import org.apache.skywalking.oap.server.core.query.entity.TraceBrief;
-import org.apache.skywalking.oap.server.core.query.entity.TraceState;
+import org.apache.skywalking.oap.server.core.query.entity.*;
 import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO;
 import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
 import org.apache.skywalking.oap.server.library.util.BooleanUtils;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
+import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.*;
 import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.index.query.BoolQueryBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.index.query.RangeQueryBuilder;
+import org.elasticsearch.index.query.*;
 import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.elasticsearch.search.sort.SortOrder;
@@ -80,7 +70,8 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
             boolQueryBuilder.must().add(rangeQueryBuilder);
         }
         if (!Strings.isNullOrEmpty(endpointName)) {
-            mustQueryList.add(QueryBuilders.matchPhraseQuery(SegmentRecord.ENDPOINT_NAME, endpointName));
+            String matchCName = MatchCNameBuilder.INSTANCE.build(SegmentRecord.ENDPOINT_NAME);
+            mustQueryList.add(QueryBuilders.matchPhraseQuery(matchCName, endpointName));
         }
         if (serviceId != 0) {
             boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.SERVICE_ID, serviceId));