[opencms-dev] Search on different fields of structuredcontenttype.

Sami Nygard sami.nygard at wombat.fr
Sat Jan 20 15:23:14 CET 2007


I'm having this problem that my resource type gets associated with the
wrong document factory.
Ref.:
http://mail.opencms.org/pipermail/opencms-dev/2006q2/024011.html

How did you get around this problem?
My xmlcontent custom resource type (registered in modules) shouldn't
need its own resource type class (e.g. extends A_CmsResourceType)? Just
the implementation of I_CmsDocumentFactory (I extended A_CmsVfsDocument)
for the indexing?

Thanks
/Sami

On Oct 18, 2006 02:44 PM, Jonathan Woods wrote:


> 
> PS  A couple of lessons I learned the hard way, to do with the
> necessarily multi-threaded nature of IndexSearcher (IndexReader) use:
>  
> 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.
>  
> 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.
>  
> Jon
> 
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Jonathan Woods
> Sent: 18 October 2006 13:27
> To: 'The OpenCms mailing list'
> Subject: RE: [opencms-dev] Search on different fields of
> structuredcontenttype.
> 
> 
> 
> Christoph, Sakshi -
>  
> 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.
>  
> Jon
> 
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Christoph
> Schönfeld
> Sent: 18 October 2006 11:34
> To: The OpenCms mailing list
> Subject: Re: [opencms-dev] Search on different fields of structured
> contenttype.
> 
> 
> 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 implementation of the
> interface method
> "org.opencms.search.documents.I_CmsDocumentFactory.newInstance(cms:
> CmsObject, resource: A_CmsIndexResource, language: String):
> org.apache.lucene.document.Document" should be able to add the custom
> fields you need to the returned Lucene Document.
> 
> 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).
> 
> See org.opencms.search.documents.CmsDocumentXmlPage for an example of
> such a class. It extends A_CmsVfsDocument which implements the afore
> mentioned interface.
> 
> I plan to use this approach for my own project, though I did not yet
> validate it and I do not yet know how to build the customized search
> on top of it.
> 
> 
> Christoph
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20070120/a7b0b5da/attachment.htm>


More information about the opencms-dev mailing list