You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by co...@kent.pnn.police.uk on 2002/11/19 09:15:07 UTC

RE: Re: Have I got any other option than to


Jeremy,
Thanks for this, what you suggest is what I need, but it does mean that I   
have to produce a summary element for all of my documents (could be   
tricky as they come out of a content management system - but that is a   
different story!).
If I 'patch' LuceneIndexContentHandler myself, do I just alter the source   
code as you suggest, recompile and overwrite the existing class/   
repackage into a new jar (I don't know how to do the latter unfortunately   
but I presume I can find out)?
The next part about having a special xslt presumably goes something like   
this...
<map:views>
 <map:view name="content" from-label="content">
 <map:transform src="stylesheets/search-index.xsl"/>
 <map:serialize type="xml"/>
</map:view>

with a generator of
<map:generator label="content" name="file"   
src="org.apache.cocoon.generation.FileGenerator"/>

Am I on the right lines with this????

TIA
Conrad


Conrad Crampton J
Software Solutions
Kent Police
FHQ
11 Edinburgh Square
Sutton Road
Maidstone
Kent
ME15 9BZ

(01622 652869
19 2869


 ----------
From:  cocoon-users[SMTP:cocoon-users@xml.apache.org]
Sent:  19 November 2002 04:51
To:  cocoon-users@xml.apache.org
Subject:   Re: Have I got any other option than to



The ability to do this is not built-in currently, regardless of what it
implies in the documentation.

The patch to add your own fields is very simple, we are discussing
adding this ATM on the dev list.

Just incase you are in too much of a hurry .... I have added 'title'
and 'summary' fields to my index with the following patch
(cocoon-2.1-dev):

RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/search/
LuceneIndexContentHandler.java,v
retrieving revision 1.5
diff -r1.5 LuceneIndexContentHandler.java
198c198,205
<             bodyDocument.add(Field.UnStored(lname, text.toString()));
 ---
 >               if (lname.equals("title")) {
 >                       bodyDocument.add(Field.UnIndexed(lname,
text.toString()));
 >               }
 >               if (lname.equals("summary")) {
 >                       bodyDocument.add(Field.UnIndexed(lname,
text.toString()));
 >               }
 >               // add the title/summary to both, so content is indexed
 >               bodyDocument.add(Field.UnStored(lname,
text.toString()));

What I do is to have a special xslt on my 'content-view' which strips
out everything I do not want searched, and decides what to make a
'title' and what a 'summary'.

The patch adds _every_ <title/> or <summary/> it finds to the index.

Hope this helps

regards Jeremy





On Monday, Nov 18, 2002, at 14:30 Europe/London,
conrad.crampton@kent.pnn.police.uk wrote:

>
>
> ...create my own indexing xsp page to allow me to include document
> elements in my HitWrapper object so I can output something meaningful
> as
> my search results?
>
> I can't find anything out there that shows how to use the cocoon
> specific
> classes to include things like <title> element or other custom xml
> elements in the index.
> I have iterated over the Fields enumeration object of the
> lucene.Document
> and have only the url field available (included in the index).
> However, I
> can perform searches like
>
> heading:sometext
>
> and this is only performed on these xml elements, so why can't I get
> 'heading' output in the Hits object???
>
> This is driving me potty. Do I have to write my own class using the
> lucene classes if I am to get this to work, if so, it seems pretty
> pointless in having the index example (and specific lucene cocoon
> classes) if all you can output is the url - not very user friendly.
>
> TIA
> Conrad
>
>
>
> Conrad Crampton J
> Software Solutions
> Kent Police
> FHQ
> 11 Edinburgh Square
> Sutton Road
> Maidstone
> Kent
> ME15 9BZ
>
> (01622 652869
> 19 2869
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>


 ---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Have I got any other option than to

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Tuesday, Nov 19, 2002, at 08:15 Europe/London, 
conrad.crampton@kent.pnn.police.uk wrote:

>
>
> Jeremy,
> Thanks for this, what you suggest is what I need, but it does mean 
> that I
> have to produce a summary element for all of my documents (could be
> tricky as they come out of a content management system - but that is a
> different story!).
> If I 'patch' LuceneIndexContentHandler myself, do I just alter the 
> source
> code as you suggest, recompile and overwrite the existing class/
> repackage into a new jar (I don't know how to do the latter 
> unfortunately
> but I presume I can find out)?

yes, modify the file and recompile
read the docs about how to compile Cocoon

> The next part about having a special xslt presumably goes something 
> like
> this...
> <map:views>
>  <map:view name="content" from-label="content">
>  <map:transform src="stylesheets/search-index.xsl"/>
>  <map:serialize type="xml"/>
> </map:view>
>

right again

> with a generator of
> <map:generator label="content" name="file"
> src="org.apache.cocoon.generation.FileGenerator"/>
>

if you are using files, yes, it will work with any Generator
all Generators are preset with the 'content' view.

I needed to get my content from a different part of my pipeline, 
because I use CInclude aggregation, I set up a new view for this called 
'include'.

my pipeline looks like this:

	<map:generate src="content/{res}.xml"/>
	<map:transform src="parts/xsl/components.xsl">
		<map:parameter name="res" value="{res}"/>
		<map:parameter name="id" value="{id}"/>
	</map:transform>
	<map:transform type="cinclude" label="include"/> <!-- new view -->
	<map:transform src="parts/xsl/get-chapter-links.xsl"/>
	<map:transform src="parts/xsl/make-chapter-links.xsl"/>
	<map:transform src="parts/xsl/doc2html.xsl">
		<map:parameter name="res" value="{res}"/>
		<map:parameter name="prefix" value="{prefix}"/>
		<map:parameter name="display" value="{display}"/>
	</map:transform>
	<map:serialize/>								
and my view looks like this:

   <map:view from-label="include" name="content">
    <map:transform src="parts/xsl/search-filter.xsl"/>
    <map:serialize type="xml"/>
   </map:view>

you can see how I have mapped the 'include' view to the 'content' view.
one day the view used by the indexer will be configurable (ATM is is 
fixed as 'content'), so you can choose whatever view you like, directly


> Am I on the right lines with this????

looks like it


regards Jeremy


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>