[opencms-dev] Customise search ERROR [OpenCMS 6.0] (resend)
Alexander Kandzior
alex at opencms.org
Sat Jul 30 10:14:11 CEST 2005
David,
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().
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.
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.
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com <http://www.alkacon.com/>
_____
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of David
Sent: Friday, July 29, 2005 12:44 PM
To: The OpenCms mailing list
Subject: [opencms-dev] Customise search ERROR [OpenCMS 6.0] (resend)
Hi,
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 No analyzer found for language "null". 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.
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.
Rgds,
David.
// Define the document set from files
ArrayList docPaths = new ArrayList();
docPaths.add("/sites/mysite/file1.doc");
docPaths.add("/sites/mysite/file2.pdf");
docPaths.add("/sites/mysite/file3.txt");
String query = "hello*";
// Define index source
CmsSearchIndexSource indexSource = new CmsSearchIndexSource();
indexSource.setName("tempIndexSource");
indexSource.setIndexerClassName(" org.opencms.search.CmsVfsIndexer");
indexSource.addDocumentType("xmlpage");
indexSource.addDocumentType("xmlcontent");
indexSource.addDocumentType("page");
indexSource.addDocumentType ("text");
indexSource.addDocumentType("pdf");
indexSource.addDocumentType("rtf");
indexSource.addDocumentType("html");
indexSource.addDocumentType("msword");
indexSource.addDocumentType("msexcel");
indexSource.addDocumentType("mspowerpoint");
indexSource.addDocumentType("image");
indexSource.addDocumentType("generic");
// Add documents to index source
for (Iterator pointerIt = docPaths.iterator(); pointerIt.hasNext();) {
String pointer = (String) pointerIt.next();
// create a document object from this pointer
indexSource.addResourceName(pointer);
}
// Instantiate an index from the index source
CmsSearchIndex index = new CmsSearchIndex();
index.setName("tempIndex");
index.addSourceName(indexSource.getName());
index.setLocale("en");
index.setRebuildMode(CmsSearchIndex.AUTO_REBUILD);
index.initialize();
// Test to make sure analyzer for locale 'en' exists
CmsSearchManager searchMgr = OpenCms.getSearchManager();
CmsSearchAnalyzer analyzer = (CmsSearchAnalyzer)
searchMgr.getAnalyzers().get("en");
out.println ("Analyzer for locale 'en' is "+analyzer.getClassName());
// Update the index (build it)
searchMgr.addAnalyzer(analyzer);
searchMgr.addSearchIndexSource(indexSource);
searchMgr.addSearchIndex(index);
searchMgr.updateIndex(index.getName());
// Code to search using this indexer...
<<< ERROR TRACE MESSAGE >>>>
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 .....
...... (omitted)
<<<ERROR>>>>
--
Rgds,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20050730/e1db48dc/attachment.htm>
More information about the opencms-dev
mailing list