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

krisztiankasa pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new 54c20c3  AMBARI-25090 - Logsearch should index keywords without the 
ending periods(.) (#2791)
54c20c3 is described below

commit 54c20c3f3cea38ef601ea111c83351f02575403d
Author: kasakrisz <33458261+kasakr...@users.noreply.github.com>
AuthorDate: Wed Jan 30 10:57:55 2019 +0100

    AMBARI-25090 - Logsearch should index keywords without the ending 
periods(.) (#2791)
---
 .../solr/search/SearchServiceLogsTest.java         | 73 ++++++++++++++--------
 .../main/configsets/audit_logs/conf/managed-schema |  2 +-
 .../configsets/hadoop_logs/conf/managed-schema     |  2 +-
 3 files changed, 50 insertions(+), 27 deletions(-)

diff --git 
a/ambari-logsearch/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
 
b/ambari-logsearch/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
index b7766c9..2dfe5f3 100644
--- 
a/ambari-logsearch/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
+++ 
b/ambari-logsearch/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
@@ -166,18 +166,21 @@ public class SearchServiceLogsTest {
   @Test
   public void testIncludeMultipleTermsDelimitedByDash() throws Exception {
     solr.addDoc("0", "Unhandled exception");
-    solr.addDoc("1", "At line 112 an unhandled-exception occurred when");
-    solr.addDoc("2", "exception occurred");
-    solr.addDoc("3", "exception");
-    solr.addDoc("4", "Unhandled error");
-    solr.addDoc("5", "Error occurred");
+    solr.addDoc("1", "Unhandled+exception");
+    solr.addDoc("2", "At line 112 an unhandled-exception occurred when");
+    solr.addDoc("3", "exception occurred");
+    solr.addDoc("4", "exception");
+    solr.addDoc("5", "Unhandled error");
+    solr.addDoc("6", "Error occurred");
 
     BaseServiceLogRequest request = new BaseServiceLogQueryRequest();
     
request.setIncludeQuery("[{\"log_message\":\"\\\"Unhandled-exception\\\"\"}]");
     SolrDocumentList found = executeQuery(request);
 
-    assertThat(found, hasSize(1));
+    assertThat(found, hasSize(3));
+    assertThat(found, hasItem(solrDoc("0")));
     assertThat(found, hasItem(solrDoc("1")));
+    assertThat(found, hasItem(solrDoc("2")));
   }
 
   @Test
@@ -194,8 +197,10 @@ public class SearchServiceLogsTest {
     
request.setIncludeQuery("[{\"log_message\":\"\\\"Unhandled+exception\\\"\"}]");
     SolrDocumentList found = executeQuery(request);
 
-    assertThat(found, hasSize(1));
+    assertThat(found, hasSize(3));
+    assertThat(found, hasItem(solrDoc("0")));
     assertThat(found, hasItem(solrDoc("1")));
+    assertThat(found, hasItem(solrDoc("2")));
   }
 
   @Test
@@ -232,31 +237,22 @@ public class SearchServiceLogsTest {
   @Test
   public void testIncludeEMailAddress() throws Exception {
     solr.addDoc("0", "Email address: j...@hortonworks.com");
-    solr.addDoc("1", "Another document");
-
+    solr.addDoc("1", "Another document d...@hortonworks.com");
+    solr.addDoc("2", "Another document without email address");
+    solr.addDoc("3", "Just a name and a domain name: john hortonworks.com");
+    solr.addDoc("4", "Hi name is John Domain name: hortonworks.com");
     BaseServiceLogRequest request = new BaseServiceLogQueryRequest();
-    request.setIncludeQuery("[{\"log_message\":\"j...@hortonworks.com\"}]");
+    
request.setIncludeQuery("[{\"log_message\":\"\\\"j...@hortonworks.com\\\"\"}]");
     SolrDocumentList found = executeQuery(request);
 
-    assertThat(found, hasSize(1));
+    assertThat(found, hasSize(2));
     assertThat(found, hasItem(solrDoc("0")));
+    assertThat(found, hasItem(solrDoc("3")));
   }
 
 
   private final ServiceLogLevelDateRangeRequestQueryConverter 
dateRangeRequestQueryConverter = new 
ServiceLogLevelDateRangeRequestQueryConverter();
 
-  @Test
-  public void testDateRangeRequestIncludeEMailAddress() throws Exception {
-    solr.addDoc("0", "Email address: j...@hortonworks.com");
-    solr.addDoc("1", "Another document d...@hortonworks.com");
-
-    ServiceGraphRequest request = 
serviceGraphRequest("[{\"log_message\":\"j...@hortonworks.com\"}]");
-    NamedList<List<PivotField>> found = executeQuery(request);
-
-    assertThat(found.size(), is(1));
-    assertThat(found.get("level").get(0).getCount(), is(1));
-  }
-
   private ServiceGraphRequest serviceGraphRequest(String includeQuery) {
     ServiceGraphRequest request = new ServiceGraphQueryRequest();
     
request.setFrom(SOLR_DATETIME_FORMATTER.format(OffsetDateTime.now(ZoneId.of("UTC")).minusDays(1)));
@@ -327,7 +323,7 @@ public class SearchServiceLogsTest {
     NamedList<List<PivotField>> found = executeQuery(request);
 
     assertThat(found.size(), is(1));
-    assertThat(found.get("level").get(0).getCount(), is(1));
+    assertThat(found.get("level").get(0).getCount(), is(2));
   }
 
   @Test
@@ -344,7 +340,7 @@ public class SearchServiceLogsTest {
     NamedList<List<PivotField>> found = executeQuery(request);
 
     assertThat(found.size(), is(1));
-    assertThat(found.get("level").get(0).getCount(), is(1));
+    assertThat(found.get("level").get(0).getCount(), is(3));
   }
 
   @Test
@@ -373,4 +369,31 @@ public class SearchServiceLogsTest {
     assertThat(found.size(), is(1));
     assertThat(found.get("level").get(0).getCount(), is(3));
   }
+
+  @Test
+  public void testSearchTermEndsWithDot() throws Exception {
+    solr.addDoc("0", "Caught exception checkIn.");
+    solr.addDoc("1", "Caught exception checkIn");
+    solr.addDoc("2", "Caught exception other");
+
+    BaseServiceLogRequest request = new BaseServiceLogQueryRequest();
+    request.setIncludeQuery("[{\"log_message\":\"\\\"checkIn\\\"\"}]");
+    SolrDocumentList found = executeQuery(request);
+
+    assertThat(found, hasSize(2));
+    assertThat(found, hasItem(solrDoc("0")));
+    assertThat(found, hasItem(solrDoc("1")));
+  }
+
+  @Test
+  public void testSearchPhraseContainsStar() throws Exception {
+    solr.addDoc("0", "Caught exception- checkIn");
+
+    BaseServiceLogRequest request = new BaseServiceLogQueryRequest();
+    request.setIncludeQuery("[{\"log_message\":\"\\\"Caught 
exception*\\\"\"}]");
+    SolrDocumentList found = executeQuery(request);
+
+    assertThat(found, hasSize(1));
+    assertThat(found, hasItem(solrDoc("0")));
+  }
 }
diff --git 
a/ambari-logsearch/ambari-logsearch-server/src/main/configsets/audit_logs/conf/managed-schema
 
b/ambari-logsearch/ambari-logsearch-server/src/main/configsets/audit_logs/conf/managed-schema
index 6896918..4715f07 100644
--- 
a/ambari-logsearch/ambari-logsearch-server/src/main/configsets/audit_logs/conf/managed-schema
+++ 
b/ambari-logsearch/ambari-logsearch-server/src/main/configsets/audit_logs/conf/managed-schema
@@ -91,7 +91,7 @@
   <field name="ip" type="key_lower_case"/>
   <field name="level" type="key_lower_case"/>
   <field name="logType" type="key_lower_case" multiValued="false"/>
-  <field name="log_message" type="text_ws" multiValued="false" 
omitNorms="false"/>
+  <field name="log_message" type="text_std_token_lower_case" 
multiValued="false" omitNorms="false"/>
   <field name="logfile_line_number" type="tint" omitNorms="false"/>
   <field name="logger_name" type="key_lower_case"/>
   <field name="message_md5" type="string" multiValued="false"/>
diff --git 
a/ambari-logsearch/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
 
b/ambari-logsearch/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
index 168427e..b1fda99 100644
--- 
a/ambari-logsearch/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
+++ 
b/ambari-logsearch/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
@@ -96,7 +96,7 @@
   <field name="ip" type="string" multiValued="false"/>
   <field name="level" type="lowercase" multiValued="false"/>
   <field name="line_number" type="tint" omitNorms="false"/>
-  <field name="log_message" type="text_ws" multiValued="false" 
omitNorms="false"/>
+  <field name="log_message" type="text_general" multiValued="false" 
omitNorms="false"/>
   <field name="logfile_line_number" type="tint" omitNorms="false"/>
   <field name="logger_name" type="string" multiValued="false"/>
   <field name="logtime" type="tdate" multiValued="false"  docValues="true"/>

Reply via email to