<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2>Sami -</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2>You're right - there's no need to create a new class to
represent your custom content; the resource type is still OpenCms's XML content
type.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2>The resource type is _not_ the same as the search config's
so-called document type, which as you know is defined in
opencms-search.xml. It may be coincidentally named the same, but that's as
far as it goes. If you look in opencms-search.xml as it ships with
OpenCms, you'll see a <documenttype> node for a document type called
'xmlcontent'. All you need is to create another entry, named however you
like - but for clarity probably using the same name as your resource type
- and with your own implementation of I_CmsDocument.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN><SPAN class=781321619-20012007><FONT
face=Arial color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2>When you've added this, don't forget also to include your
new document type later on in the opencms-search.xml file, underneath the
<indexsources><indexsource><documenttypes-indexed> node...
otherwise it won't ever be indexed.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2>You may find you also need to remove the first entry in
opencms-search.xml, the one which maps a resource type '*' to a document type
called 'generic'. I can't recall now, but I think I had to do that to stop
my XML content from being indexed by the wrong Lucene document factory -
certainly everything's working fine without it.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=781321619-20012007><FONT face=Arial
color=#0000ff size=2>Jon</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> sfdbfoui@host2.scintillance.com
[mailto:sfdbfoui@host2.scintillance.com] <B>On Behalf Of </B>Sami
Nygard<BR><B>Sent:</B> 20 January 2007 14:23<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>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="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,38,255) 2px solid; MARGIN-RIGHT: 5px">
<DIV dir=ltr align=left><SPAN class=526053412-18102006><FONT face=Arial
color=#0000ff 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 face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=526053412-18102006><FONT face=Arial
color=#0000ff 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 face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=526053412-18102006><FONT face=Arial
color=#0000ff 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 face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=526053412-18102006><FONT face=Arial
color=#0000ff size=2>Jon</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us 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>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 face=Arial
color=#0000ff size=2>Christoph, Sakshi -</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=885562212-18102006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=885562212-18102006><FONT face=Arial
color=#0000ff 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 face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=885562212-18102006><FONT face=Arial
color=#0000ff size=2>Jon</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us 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>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>