_________________________________________________________________
Latinos en EE.UU: noticias y art�culos de inter�s para ti http://latino.msn.com/noticias/latinoseneeuu
Index: src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java
===================================================================
RCS file: /home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java,v
retrieving revision 1.11
diff -u -r1.11 LuceneSearchService.java
--- src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java 19 May 2004 21:04:41 -0000 1.11
+++ src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java 16 Jun 2004 15:35:59 -0000
@@ -85,6 +85,10 @@
private File rootDir = null;
private String indexRoot = null;


+ private static final String DEFAULT_ANALYZER_CLASS_NAME = "org.apache.lucene.analysis.standard.StandardAnalyzer";
+ private static final String CONFIG_ANALYZER_CLASS_NAME = "analyzer";
+ private String analyzerClassName = null;
+
/**
* This is the early initialization method called by the
* Turbine <code>Service</code> framework
@@ -192,7 +196,7 @@
{
try
{
- IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), true);
+ IndexWriter indexWriter = new IndexWriter(rootDir, newAnalyzer(), true);
indexWriter.close();
indexWriter = null;
logger.info("Created Lucene Index in " + rootDir.getPath());
@@ -204,6 +208,9 @@
}
}


+ // Get analyze class name
+ analyzerClassName = serviceConf.getString(CONFIG_ANALYZER_CLASS_NAME, DEFAULT_ANALYZER_CLASS_NAME);
+
//Mark that we are done
setInit(true);
}
@@ -231,7 +238,7 @@
return null;
}


-        Analyzer analyzer = new StandardAnalyzer();
+        Analyzer analyzer = newAnalyzer();

String[] searchFields = {ParsedObject.FIELDNAME_CONTENT, ParsedObject.FIELDNAME_DESCRIPTION, ParsedObject.FIELDNAME_FIELDS,
ParsedObject.FIELDNAME_KEY, ParsedObject.FIELDNAME_KEYWORDS, ParsedObject.FIELDNAME_LANGUAGE,
@@ -407,7 +414,7 @@
IndexWriter indexWriter;
try
{
- indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
+ indexWriter = new IndexWriter(rootDir, newAnalyzer(), false);
}
catch (IOException e)
{
@@ -620,7 +627,7 @@


            indexReader.close();

- IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
+ IndexWriter indexWriter = new IndexWriter(rootDir, newAnalyzer(), false);
indexWriter.optimize();
indexWriter.close();


@@ -683,4 +690,25 @@
        return false;
    }

+
+    private Analyzer newAnalyzer() {
+        Analyzer rval = null;
+
+        try {
+            Class analyzerClass = Class.forName(analyzerClassName);
+            rval = (Analyzer) analyzerClass.newInstance();
+        } catch(InstantiationException e) {
+            logger.error("InstantiationException", e);
+        } catch(ClassNotFoundException e) {
+            logger.error("ClassNotFoundException", e);
+        } catch(IllegalAccessException e) {
+            logger.error("IllegalAccessException", e);
+        }
+
+        if(rval == null) {
+            rval = new StandardAnalyzer();
+        }
+
+        return rval;
+    }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to