[opencms-dev] Search question

Rudolf Blazek opencms at blazek.net
Tue Oct 31 12:23:05 CET 2006


I solved it! Well, sort of, it's a mystery. I wonder if I made some  
mistake in the configs. I thought the info might be useful to some,  
so here it goes:

1) What worked:
Searching in Workplace/Admin/SearchMgmt worked just fine

2) What did not work:
Searching in templateone and using /alkacon-documentation/ 
examples_search/
In the search example under the Alcacon Docs my index does not work,  
but other indexes work fine.

3) What was the trick:
When I copied the search examples folder to my site, either none or  
all of the indexes worked.

I tried this while logged into the workplace:
None worked when I selected location "/sites/MySite".
All worked when I selected location "/".

This does PARTLY apply also to the original search demo in
/sites/default/alkacon-documentation/examples_search/
More precisely
a) Selecting the location has no effect on the original search index  
for the online project
b) Selecting the "/" location makes my search index work

This is REALLY weird.


4) Workaround

Edit any search page you want to use and set the SiteRoot as "/"  
temporarily just for the search duration. Code for templateone is  
enclosed below.


5) Comments. I read the source code for quite a while and there seems  
ti be NO reason why this should be different from setting the search  
root as "/". But it is. I did not read the all code in  
CmsSearchIndex.search() since it was too much 'lucene' stuff and I  
did not have time. If you have any clue what is going on, please do  
let me know.

Just as a note, I have the following sites setup in opecms- 
system.xml, and they do work just fine
     <sites>
       <workplace-server>http://opencms.myserver.com</workplace-server>
       <default-uri>/sites/MySite/</default-uri>
       <site server="http://opencms.myserver.com" uri="/sites/ 
default/"/>
       <site server="http://www.myserver.com" uri="/sites/MySite/"/>
     </sites>


6) Modification of templateone
This will enable templateone searching in custom sites, but will  
disable searching in microsites.

Edit the following file and make the changes listed below
/system/modules/org.opencms.frontend.templateone/pages/search.html


Best of luck, let me know what you think. It's really a mystery to me...


Rudy




---- change 1 vvv -----

if (cms.isSearchAllDisplayed()) {  // Rudy's workaround

---- change to -----

/* Rudy Blazek's Search Index Workaround <opencms at blazek.net>.
  * Setting the SiteRoot as "/" makes the search index work.
  * Setting the search root as "/" does not!!)
  */
String tmpSiteRoot = cms.getRequestContext().getSiteRoot(); // Rudy's  
workaround
cms.getRequestContext().setSiteRoot("/");                   // Rudy's  
workaround
/*
  * Disable searching of microsites; search the whole site instead
  */
cms.setSearchAll(true);              // Rudy's workaround
//if (cms.isSearchAllDisplayed()) {  // Rudy's workaround
if (false) {                         // Rudy's workaround

---- change 1 ^^^ -----






---- change 2 vvv -----

// get the search results for the page
List result = cms.getSearchResults(search);

---- change to -----

// get the search results for the page
List result = cms.getSearchResults(search);
/*
  * Restore the SiteRoot!
  */
cms.getRequestContext().setSiteRoot(tmpSiteRoot); // Rudy's workaround

---- change 2 ^^^ -----





On Oct 31, 2006, at 3:27 PM, Jonathan Woods wrote:

> I know you mentioned searching via the workplace, but I wondered if  
> that meant you'd tried Workplace/Administration/Search management.   
> You can search in specific indexes there, and see the effects of  
> changing index configuration - that might shed some light on things.
>
> I'd like to be more help, but I ignored templateone completely and  
> started from a clean slate...
>
> Jon
>
> From: opencms-dev-bounces at opencms.org [mailto:opencms-dev- 
> bounces at opencms.org] On Behalf Of Rudolf Blazek
> Sent: 31 October 2006 03:16
> To: The OpenCms mailing list
> Subject: Re: [opencms-dev] Search question
>
> And by 'index does not work' I mean that the search returns 0  
> matches or an error message "Your search had no matches!"
> Rudy
>
> On Oct 31, 2006, at 11:02 AM, Rudolf Blazek wrote:
>
>> On Oct 30, 2006, at 9:34 PM, Jonathan Woods wrote:
>>
>>> Rudy -
>>>
>>> What do you mean by 'deployed site'?
>>
>>
>> Hi Jon, by deployed site I mean the 'online project' while I am  
>> logged OUT of the workplace. I.e. the site as it is accessible by  
>> the public.
>>
>>> If you say search works on any
>>> project, then it works in the online project, i.e. outside the  
>>> workplace.
>>
>> The search works inside the workplace in the search manager. I can  
>> set the project in the workplace pop-up to Online, Offline or  
>> MySite Project. And the location in the pop-up can be either / or / 
>> sites/default/ or /sites/MySite. The index does search properly.
>>
>> When I try to use the search example pages under the Alcacon Docs,  
>> my index does not work when I select it. But other indexes work.  
>> The examples are at /alkacon-documentation/examples_search/
>>
>> When I copy the search examples folder to my site, none of the  
>> indexes work.
>>
>>> I'm not trying to be awkward, but I wonder if this thread helps:
>>>
>>> http://www.nabble.com/Lucene-search-config-tf322880.html#a899675
>>
>> Yeah, I followed all of those instructions step by step. No luck.  
>> I am not sure what I did wrong.
>>
>> Any help would be greatly appreciated
>>
>> Rudy
>>
>> Here is my index definition:
>>
>> <index>
>> <name>/sites/MySite</name>
>> <rebuild>auto</rebuild>
>> <project>Online</project>
>> <locale>en</locale>
>> <sources>
>> <source>My Website</source>
>> </sources>
>> </index>
>> .......
>> <indexsource>
>> <name>My Website</name>
>> <indexer class="org.opencms.search.CmsVfsIndexer"/>
>> <resources>
>> <resource>/sites/MySite/</resource>
>> </resources>
>> <documenttypes-indexed>
>> <name>generic</name>
>> <name>xmlpage</name>
>> <name>xmlcontent</name>
>> <name>text</name>
>> <name>rtf</name>
>> <name>pdf</name>
>> <name>msword</name>
>> <name>mspowerpoint</name>
>> <name>msexcel</name>
>> <name>jsp</name>
>> <name>image</name>
>> <name>html</name>
>> </documenttypes-indexed>
>> </indexsource>
>>
>>
>>
>>
>>
>>
>>>
>>> Jon
>>>
>>> -----Original Message-----
>>> From: opencms-dev-bounces at opencms.org
>>> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Rudolf Blazek
>>> Sent: 30 October 2006 13:19
>>> To: opencms-dev at opencms.org
>>> Subject: [opencms-dev] Search question
>>>
>>> Dear List:
>>>
>>> Please excuse me, but I need to ask a very simple question that  
>>> was asked
>>> but not answered before:
>>>
>>> Did anyone succeed with search using templateone?
>>>
>>>
>>> My situation is as usual: I have a site in /sites/MySite and the  
>>> index works
>>> fine when tested in the workplace under ANY project and under ANY  
>>> location.
>>> Yet, the search is empty on the deployed site.
>>>
>>> I read several lists, I setup my index (named /sites/MySite), I  
>>> tried
>>> everything I could find. I even rewired the search page in  
>>> templateone to
>>> search my index when using the demo pages. The built- in search in
>>> templateone just does NOT work with my index.
>>>
>>> Is there something I am missing? I am sure it's some silly mistake.
>>> And no, I do not want to abandon templateone and I am not asking  
>>> how to
>>> write my own search page...
>>>
>>> Thanks
>>> Rudy
>>>
>>>
>>> P.S.: Please understand that I am really lost. So, please do not  
>>> answer
>>> "There was a cool thread last week about this". Please post a  
>>> link, or the
>>> subject or some other thread reference. I really appreciate your  
>>> help.
>>> Thanks, Rudy
>>>
>>> _______________________________________________
>>> This mail is sent to you from the opencms-dev mailing list To  
>>> change your
>>> list options, or to unsubscribe from the list, please visit
>>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>>>
>>>
>>>
>>> _______________________________________________
>>> This mail is sent to you from the opencms-dev mailing list
>>> To change your list options, or to unsubscribe from the list,  
>>> please visit
>>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>>
>>
>> _______________________________________________
>> This mail is sent to you from the opencms-dev mailing list
>> To change your list options, or to unsubscribe from the list,  
>> please visit
>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list,  
> please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list