<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2668" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2>David,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2>keep in mind that the archtecture is based around the
CmsSearchManager, so you need to register your index sources there in order to
use them later. So for example you are calling CmsSearchindex.initialize() befor
you add the index source to the search manager. You may tra to add the
initialize() call just befor capping updateIndex().</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2>On the other hand, you should consider bulding one index
that hold all your resources and then using
CmsSearch#setSearchRoots(String[]) to limit the search dynamically to a set of
resources. You will not have the overhead of multiple index ceration this way,
and the results will be found likewise fast. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=241130008-30072005><FONT face=Arial
color=#0000ff size=2>One last thing: There have been made some changes in the
search API (renaming of methods) in the current CVS HEAD since we have been
adding new features to the search, like dynamically updating of search indexes
after publish recently. Also there will be a new Admin backoffice for managing
the indexes soon.</FONT></SPAN></DIV><!-- Converted from text/plain format -->
<P><FONT size=2>Best Regards,<BR>Alex.<BR><BR>Alexander Kandzior<BR>Alkacon
Software - The OpenCms Experts<BR><A
href="http://www.alkacon.com/">http://www.alkacon.com</A><BR><BR></FONT></P>
<DIV> </DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=de dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> opencms-dev-bounces@opencms.org
[mailto:opencms-dev-bounces@opencms.org] <B>On Behalf Of
</B>David<BR><B>Sent:</B> Friday, July 29, 2005 12:44 PM<BR><B>To:</B> The
OpenCms mailing list<BR><B>Subject:</B> [opencms-dev] Customise search ERROR
[OpenCMS 6.0] (resend)<BR></FONT><BR></DIV>
<DIV></DIV><SPAN class=gmail_quote></SPAN>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>I am trying to customise the search behaviour in OpenCMS such that to
allow an application to dynamically create a new index source and search index
from an arbitrary set of files in VFS and perform a search on those files. The
code that I am using is given below. When I run this from a JSP page it
returned with an error saying <EM>No analyzer found for language "null".
</EM>The trace log for this error is given at the bottom which points to
method getAnalyzer() in CmsSearchManager. So I checked the source code of this
method and it looks perfectly normal given that I already set the locale for
my CmsSearchIndex object to 'en'. I even test printing out the analyzer class
name (see code) using getAnalyzers() method of the CmsSearchManager to make
sure that analyzer for 'en' locale exists. </DIV>
<DIV> </DIV>
<DIV>So the analyzer is there and the locale has been set for the
CmsSearchIndex object, why does it still complain about the analyzer being not
found and weird enough in the error message it seems not able to detect the
locale ("null" value)? Has anyone experienced this before and perhaps could
provide some insights? Thanks very much for your prompt response. </DIV>
<DIV> </DIV>
<DIV>Rgds,</DIV>
<DIV>David.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>// Define the document set from files<BR>ArrayList docPaths = new
ArrayList();<BR>docPaths.add("/sites/mysite/file1.doc");<BR>docPaths.add("/sites/mysite/file2.pdf");<BR>docPaths.add("/sites/mysite/file3.txt");
<BR>String query = "hello*";<BR>// Define index source<BR>CmsSearchIndexSource
indexSource = new
CmsSearchIndexSource();<BR>indexSource.setName("tempIndexSource");<BR>indexSource.setIndexerClassName("
org.opencms.search.CmsVfsIndexer");<BR>indexSource.addDocumentType("xmlpage");<BR>indexSource.addDocumentType("xmlcontent");<BR>indexSource.addDocumentType("page");<BR>indexSource.addDocumentType
("text");<BR>indexSource.addDocumentType("pdf");<BR>indexSource.addDocumentType("rtf");<BR>indexSource.addDocumentType("html");<BR>indexSource.addDocumentType("msword");<BR>indexSource.addDocumentType("msexcel");<BR>indexSource.addDocumentType("mspowerpoint");<BR>indexSource.addDocumentType("image");<BR>indexSource.addDocumentType("generic");</DIV>
<DIV>
<P>// Add documents to index source<BR>for (Iterator pointerIt =
docPaths.iterator(); pointerIt.hasNext();) {<BR> String
pointer = (String) pointerIt.next();<BR> // create a
document object from this pointer<BR>
indexSource.addResourceName(pointer);<BR>}</P>
<P>// Instantiate an index from the index source<BR>CmsSearchIndex index = new
CmsSearchIndex();<BR>index.setName("tempIndex");<BR>index.addSourceName(indexSource.getName());
<BR>index.setLocale("en");
<BR>index.setRebuildMode(CmsSearchIndex.AUTO_REBUILD);<BR>index.initialize();</P>
<P>// Test to make sure analyzer for locale 'en' exists<BR>CmsSearchManager
searchMgr = OpenCms.getSearchManager();<BR>CmsSearchAnalyzer analyzer =
(CmsSearchAnalyzer) searchMgr.getAnalyzers().get("en");<BR>out.println
("Analyzer for locale 'en' is "+analyzer.getClassName());</P>
<P>// Update the index (build
it)<BR>searchMgr.addAnalyzer(analyzer);<BR>searchMgr.addSearchIndexSource(indexSource);<BR>searchMgr.addSearchIndex(index);<BR>searchMgr.updateIndex(index.getName());</P>
<P>// Code to search using this indexer...</P>
<P> </P>
<P><<< ERROR TRACE MESSAGE >>>></P><PRE><HTML><PRE>org.opencms.search.CmsIndexException: No analyzer found for language "null".
at org.opencms.search.CmsSearchManager.getAnalyzer(CmsSearchManager.java:692)
at org.opencms.search.CmsSearchIndex.getIndexWriter(CmsSearchIndex.java:328)
at org.opencms.search.CmsSearchManager.updateIndex(CmsSearchManager.java:600)
at org.opencms.search.CmsSearchManager.updateIndex(CmsSearchManager.java:557)
at org.opencms.search.CmsSearchManager.updateIndex(CmsSearchManager.java:544)
at .....</PRE><PRE>...... (omitted)</PRE></PRE>
<P><<<ERROR>>>></P></DIV><BR clear=all><BR>--
<BR>Rgds,<BR>David </BLOCKQUOTE></BODY></HTML>