<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta name="generator" content="SuSE Linux Openexchange Server 4">
<title></title>
</head>
<body>
I'm having this problem that my resource type gets associated with the wrong document factory.<br>Ref.:<br>http://mail.opencms.org/pipermail/opencms-dev/2006q2/024011.html<br><br>How did you get around this problem?<br>My xmlcontent custom resource type (registered in modules) shouldn't need its own resource type class (e.g. extends A_CmsResourceType)? Just the <font face="Helvetica, Arial, sans-serif">implementation of I_CmsDocumentFactory (I extended A_CmsVfsDocument) for the indexing?<br><br>Thanks<br>/Sami<br></font><br>On Oct 18, 2006 02:44 PM, Jonathan Woods <jonathan.woods@scintillance.com> wrote:<br><br></jonathan.woods@scintillance.com><blockquote style="border-left: 2px solid rgb(0, 38, 255); padding-right: 5px; padding-left: 5px; margin-left: 5px; margin-right: 5px;"> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2">PS A couple of lessons I learned the hard way, to do with the necessarily multi-threaded nature of IndexSearcher (IndexReader) use:</font></span></div> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2">1. An IndexSearcher becomes invalid when changes are made to the underlying index elsewhere. To test for this condition before using other IndexSearcher methods, test indexSearcher.getIndexReader().isCurrent(). Even that doesn't guarantee currency, because the index could be changed after your test but before your use of it... so you still have to handle Exceptions.</font></span></div> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2">2. Although we're told it's a good idea to call close() on an IndexSearcher once it's invalid, note that other threads which still expect to use it will receive an IOException ('bad file descriptor') if they try to access an IndexSearcher which has already been closed.</font></span></div> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="526053412-18102006"><font color="#0000ff" face="Arial" size="2">Jon</font></span></div><br> <div class="OutlookMessageHeader" dir="ltr" align="left" lang="en-us"> <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>Jonathan Woods<br><b>Sent:</b> 18 October 2006 13:27<br><b>To:</b> 'The OpenCms mailing list'<br><b>Subject:</b> RE: [opencms-dev] Search on different fields of structuredcontenttype.<br></font><br></div> <div></div> <div dir="ltr" align="left"><span class="885562212-18102006"><font color="#0000ff" face="Arial" size="2">Christoph, Sakshi -</font></span></div> <div dir="ltr" align="left"><span class="885562212-18102006"><font color="#0000ff" face="Arial" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="885562212-18102006"><font color="#0000ff" face="Arial" size="2">The approach below works fine. You need some way to get past the OpenCms search interface and into the Lucene API, so I've attached a snippet of code which gets you a Lucene IndexSearcher from the OpenCms runtime framework.</font></span></div> <div dir="ltr" align="left"><span class="885562212-18102006"><font color="#0000ff" face="Arial" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="885562212-18102006"><font color="#0000ff" face="Arial" size="2">Jon</font></span></div><br> <div class="OutlookMessageHeader" dir="ltr" align="left" lang="en-us"> <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>Christoph Schönfeld<br><b>Sent:</b> 18 October 2006 11:34<br><b>To:</b> The OpenCms mailing list<br><b>Subject:</b> Re: [opencms-dev] Search on different fields of structured contenttype.<br></font><br></div> <div></div><font face="Helvetica, Arial, sans-serif">As far as I understand OpenCms correctly what you want is possible by providing a custom Lucene Document Factory (which implements org.opencms.search.documents.I_CmsDocumentFactory) as part of your own custom OpenCms Document Type class. Your </font><font face="Helvetica, Arial, sans-serif">implementation of the interface method </font><font face="Helvetica, Arial, sans-serif">"org.opencms.search.documents.I_CmsDocumentFactory.</font><font face="Helvetica, Arial, sans-serif">newInstance(</font><font face="Helvetica, Arial, sans-serif">cms:</font><font face="Helvetica, Arial, sans-serif"> CmsObject, resource: </font><font face="Helvetica, Arial, sans-serif">A_CmsIndexResource</font><font face="Helvetica, Arial, sans-serif">, </font><font face="Helvetica, Arial, sans-serif">language:</font><font face="Helvetica, Arial, sans-serif"> String): org.apache.lucene.document.Document" should be able to </font><font face="Helvetica, Arial, sans-serif">add the custom fields you need to the </font><font face="Helvetica, Arial, sans-serif">returned </font><font face="Helvetica, Arial, sans-serif">Lucene Document.<br><br>This class has probably to appear as the "Document type class" in the search index source frontend (Administration View > Search Management > View index sources > Index source overview). <br></font><font face="Helvetica, Arial, sans-serif"><br>See org.opencms.search.documents.CmsDocumentXmlPage for an example of such a class. It extends A_CmsVfsDocument which implements the afore mentioned interface.<br></font><font face="Helvetica, Arial, sans-serif"><br>I plan to use this approach for my own project, though I did not </font><font face="Helvetica, Arial, sans-serif">yet </font><font face="Helvetica, Arial, sans-serif">validate it and I do not yet know how to build the customized search on top of it.<br></font><br><font face="Helvetica, Arial, sans-serif"><br>Christoph<br><br></font><br></blockquote><br>
</body>
</html>