[opencms-dev] Why does this search script only work in site = "/"

Andras Balogh abalogh at gmail.com
Thu Dec 15 14:01:01 CET 2005


Hello Joe,

    Since You are a nice guy and always helping on the list I will try 
to help You ;)
For me the search is working, what I have noticed that is different from 
your code is that
the field name is not "contents" but "content" and i have additionaly
setMatchesPerPage and setPage.
I'm also specifying the search roots with the method: setSearchRoots
    What i have also noticed that the index needs to be rebuilt even if 
is set to auto
at least once after you defined it. You can do this in Administration View.
I think "auto" means that the index will be rebuilt for  any *future* 
changes
but I'm not sure about this.
Aslo there is a search page on Administration where you can try your index,
it should work there after rebuilding.

Hope it helps, let me know.

Best regards,
Andras.

Joe Desbonnet wrote:

>I've been following some of the recent discussion on search indexes on
>the list. But I still can not get OpenCms search to work properly in
>my case.
>
>Here is a short JSP script which should print out the number of
>keyword hits in my index. It only returns results if run  the explorer
>while Site = "/".  I get zero hits if I set Site to my website.
>
>This must be some sort of permissions problem -- ie my site is not
>priviliged to access it's own index (??).
>
>Joe.
>
>
><%@ page buffer="none" import="org.opencms.main.*,
>org.opencms.search.*, org.opencms.file.*, org.opencms.jsp.*,
>java.util.*" %><%
>
>CmsJspActionElement cms = new CmsJspActionElement(pageContext,
>request, response);
>
>CmsSearch search = new CmsSearch();
>search.init (cms.getCmsObject());
>search.setIndex("JHL");
>search.setQuery("commerce");
>
>String[] fields = {"contents","title"};
>search.setField(fields);
>
>List result=search.getSearchResult();
>if (result == null) {
>	out.write ("got null result list");
>	return;
>}
>out.write ("got " + result.size() + " results");
>%>
>
>Here is my indexes element in opencms-search.xml:
>
><indexes>
>     <index>
>                                <name>JHL</name>
>                                <rebuild>auto</rebuild>
>                                <project>Online</project>
>                                <locale>en</locale>
>                                <sources>
>                                        <source>jhlSource</source>
>                                </sources>
>                        </index>
></indexes>
>
>Here is my sources element in opencms-search.xml:
>
> <indexsources>
>                        <indexsource>
>                                <name>jhlSource</name>
>                                <indexer
>class="org.opencms.search.CmsVfsIndexer" />
>                                <resources>
>                                       
><resource>/sites/HardimanLibrary/</resource>
>                                </resources>
>                                <documenttypes-indexed>
>                                <name>xmlpage</name>
>                                <name>xmlcontent</name>
>                                <name>page</name>
>                                <name>text</name>
>                                <name>pdf</name>
>                                <name>rtf</name>
>                                <name>html</name>
>                                <name>image</name>
>                                <name>generic</name>
>                                </documenttypes-indexed>
>                        </indexsource>
></indexsources>
>
>
>_______________________________________________
>This mail is send to you from the opencms-dev mailing list
>To change your list options, or to unsubscribe from the list, please visit
>http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>  
>




More information about the opencms-dev mailing list