You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2019/08/16 16:11:06 UTC

[jspwiki] 04/05: JSPWIKI-893: Cannot search for bold words with GermanAnalyzer

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

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 322f3c80d06a62f7317da5f965b2bc70414dec82
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 18:09:49 2019 +0200

    JSPWIKI-893: Cannot search for bold words with GermanAnalyzer
---
 .../src/main/java/org/apache/wiki/search/LuceneSearchProvider.java | 7 ++++---
 .../src/test/java/org/apache/wiki/search/SearchManagerTest.java    | 5 ++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
index 9874d63..8cca6d5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
@@ -375,7 +375,7 @@ public class LuceneSearchProvider implements SearchProvider {
      */
     protected Document luceneIndexPage( final WikiPage page, final String text, final IndexWriter writer ) throws IOException {
         if( log.isDebugEnabled() ) {
-            log.debug( "Indexing "+page.getName()+"..." );
+            log.debug( "Indexing " + page.getName() + "..." );
         }
         
         // make a new, empty document
@@ -384,13 +384,14 @@ public class LuceneSearchProvider implements SearchProvider {
         if( text == null ) {
             return doc;
         }
+        final String indexedText = text.replace( "__", " " ); // be nice to Language Analyzers - cfr. JSPWIKI-893
 
         // Raw name is the keyword we'll use to refer to this document for updates.
         Field field = new Field( LUCENE_ID, page.getName(), StringField.TYPE_STORED );
         doc.add( field );
 
         // Body text.  It is stored in the doc for search contexts.
-        field = new Field( LUCENE_PAGE_CONTENTS, text, TextField.TYPE_STORED );
+        field = new Field( LUCENE_PAGE_CONTENTS, indexedText, TextField.TYPE_STORED );
         doc.add( field );
 
         // Allow searching by page name. Both beautified and raw
@@ -411,7 +412,7 @@ public class LuceneSearchProvider implements SearchProvider {
 
         // Now add the names of the attachments of this page
         try {
-            final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments(page);
+            final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( page );
             String attachmentNames = "";
 
             for( final Attachment att : attachments ) {
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
index 22773cb..aa92b94 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
@@ -33,7 +33,7 @@ import java.util.Properties;
 
 public class SearchManagerTest {
 
-    private static final long SLEEP_TIME = 2000L;
+    private static final long SLEEP_TIME = 2_000L;
     private static final int SLEEP_COUNT = 50;
     TestEngine m_engine;
     SearchManager m_mgr;
@@ -62,8 +62,7 @@ public class SearchManagerTest {
 
     @Test
     public void testDefaultProvider() {
-        Assertions.assertEquals( "org.apache.wiki.search.LuceneSearchProvider",
-                      m_mgr.getSearchEngine().getClass().getName() );
+        Assertions.assertEquals( "org.apache.wiki.search.LuceneSearchProvider", m_mgr.getSearchEngine().getClass().getName() );
     }
 
     /**