oleewere closed pull request #70: AMBARI-25090 - Logsearch should index 
keywords without the ending periods(.)
URL: https://github.com/apache/ambari-logsearch/pull/70
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
 
b/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
index b7766c91f5..2dfe5f355e 100644
--- 
a/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
+++ 
b/ambari-logsearch-it/src/test/java/org/apache/ambari/logsearch/solr/search/SearchServiceLogsTest.java
@@ -166,18 +166,21 @@ public void testIncludeMultipleTerms() throws Exception {
   @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 void testIncludeMultipleTermsDelimitedByPlusSign() 
throws Exception {
     
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 void testIncludeMultipleWhitespaceDelimitedWords() 
throws Exception {
   @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 void 
testDateRangeRequestIncludeMultipleTermsDelimitedByDash() throws Exc
     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 void 
testDateRangeRequestIncludeMultipleTermsDelimitedByPlusSign() throws
     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 void 
testDateRangeRequestIncludeMultipleWhitespaceDelimitedWords() throws
     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-server/src/main/configsets/audit_logs/conf/managed-schema 
b/ambari-logsearch-server/src/main/configsets/audit_logs/conf/managed-schema
index 689691887a..4715f07c81 100644
--- a/ambari-logsearch-server/src/main/configsets/audit_logs/conf/managed-schema
+++ b/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-server/src/main/configsets/hadoop_logs/conf/managed-schema 
b/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
index bcc11ea86a..583e69adfd 100644
--- 
a/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
+++ 
b/ambari-logsearch-server/src/main/configsets/hadoop_logs/conf/managed-schema
@@ -97,7 +97,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"/>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to