cancel
Showing results for 
Search instead for 
Did you mean: 

How to seach in internet using alfresco's opensearch feature

javauser007
Champ in-the-making
Champ in-the-making
Hi Team,
thanks for ur help.
I read an article http://wiki.alfresco.com/wiki/OpenSearchwhich represents that we can search the document throughout internet using alfresco's opensearch.
But i didn;t found anything related to this feature in wiki. Simply wiki explains me to configuring the Remote alfresco repository.
By using wiki i'm configured to search in another alfresco repository and it is working fine.

Now i want to search throughout internet using alfresco's open search like google.
Any syntax is useful.
I just added the following peace of code to web-scripts-config-custom.xml
But it is not working. even this option is not appearing on the opensearch.

<engine label="Google Search" proxy="remote">
               <url type="application/atom+xml">
                 
               <url type="application/atom+xml">
                     http://www.google.co.in/search?hl=en&q={searchTerms}&btnG=Google+Search&meta=&aq=f&oq=
               </url>
               <url type="application/rss+xml">
                     http://www.google.co.in/search?hl=en&q={searchTerms}&btnG=Google+Search&meta=&aq=f&oq=
               </url>
         
         </engine>

The following is the error which i'm getting here.
kipped for source: classpath:alfresco/extension/web-scripts-config-custom.xml'
org.alfresco.config.ConfigException: Failed to parse config stream
        at org.alfresco.config.xml.XMLConfigService.parse(XMLConfigService.java:
177)
        at org.alfresco.config.BaseConfigService.appendConfig(BaseConfigService.
java:255)
        at org.alfresco.config.BaseConfigService.parse(BaseConfigService.java:28
5)
        at org.alfresco.config.xml.XMLConfigService.initConfig(XMLConfigService.
java:111)
        at org.alfresco.config.BaseConfigService.init(BaseConfigService.java:96)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1240)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1205)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:425)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
getBeansOfType(DefaultListableBeanFactory.java:247)
        at org.springframework.context.support.AbstractApplicationContext.getBea
nsOfType(AbstractApplicationContext.java:796)
        at org.springframework.context.support.AbstractApplicationContext.regist
erListeners(AbstractApplicationContext.java:592)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:349)
        at org.springframework.web.context.ContextLoader.createWebApplicationCon
text(ContextLoader.java:244)
        at org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:187)
        at org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:49)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:3843)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
342)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:926)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:889)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:5
16)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.dom4j.DocumentException: Error on line 51 of document  : The refe
rence to entity "q" must end with the ';' delimiter. Nested exception: The refer
ence to entity "q" must end with the ';' delimiter.
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)
        at org.dom4j.io.SAXReader.read(SAXReader.java:343)
        at org.alfresco.config.xml.XMLConfigService.parse(XMLConfigService.java:
144)
        … 47 more


Thank you for ur support.
12 REPLIES 12

mikeh
Star Contributor
Star Contributor
The error is evident in the stack trace - you need to escape the & character in XML unless presented inside a CDATA block.

Therefore & –> &amp;

Thanks,
Mike

javauser007
Champ in-the-making
Champ in-the-making

Hi Mike,
I did the modifications according to ur suggestions but still no luck.
I'm getting the following error.

org.alfresco.config.ConfigException: Failed to parse config stream

        at org.alfresco.config.xml.XMLConfigService.parse(XMLConfigService.java:

177)

        at org.alfresco.config.BaseConfigService.appendConfig(BaseConfigService.

java:255)

        at org.alfresco.config.BaseConfigService.parse(BaseConfigService.java:28

5)

        at org.alfresco.config.xml.XMLConfigService.initConfig(XMLConfigService.

java:111)

        at org.alfresco.config.BaseConfigService.init(BaseConfigService.java:96)



        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:585)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1240)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1205)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.createBean(AbstractAutowireCapableBeanFactory.java:425)

        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb

ject(AbstractBeanFactory.java:251)

        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr

y.getSingleton(DefaultSingletonBeanRegistry.java:156)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:248)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:160)

        at org.springframework.beans.factory.support.DefaultListableBeanFactory.

getBeansOfType(DefaultListableBeanFactory.java:247)

        at org.springframework.context.support.AbstractApplicationContext.getBea

nsOfType(AbstractApplicationContext.java:796)

        at org.springframework.context.support.AbstractApplicationContext.regist

erListeners(AbstractApplicationContext.java:592)

        at org.springframework.context.support.AbstractApplicationContext.refres

h(AbstractApplicationContext.java:349)

        at org.springframework.web.context.ContextLoader.createWebApplicationCon

text(ContextLoader.java:244)

        at org.springframework.web.context.ContextLoader.initWebApplicationConte

xt(ContextLoader.java:187)

        at org.springframework.web.context.ContextLoaderListener.contextInitiali

zed(ContextLoaderListener.java:49)

        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex

t.java:3843)

        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4

342)

        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase

.java:791)

        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77

1)

        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)



        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav

a:926)

        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j

ava:889)

        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492

)

        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)

        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java

:311)

        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl

eSupport.java:117)

        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)



        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)

        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)



        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443

)

        at org.apache.catalina.core.StandardService.start(StandardService.java:5

16)

        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710

)

My web-script-config-custom.xml file is having the following stuff.

     <engine label="Google Search" proxy="remote">

               <url type="application/atom+xml" >



          <![CDATA[



               <url type="application/atom+xml">

                              http://www.google.co.in/search?hl=en& q={searchTerms}&amp; btnG=Google+Search&amp; meta=&amp; aq=f&amp; oq=      

                         </url>

                         <url type="application/rss+xml">

                              http://www.google.co.in/search?hl=en& q={searchTerms}&amp; btnG=Google+Search&amp; meta=&amp; aq=f&amp; oq=   

                         </url>



               ]]>


               </engine> 

Still it is not even showing the "Google search" check box option in open search.
If we remove the "

Thank you very much for your time

mikeh
Star Contributor
Star Contributor
Hi

No, I said you need either CDATA, or to encode - you don't need both. I'd suggest just replacing & with &amp; as I suggested. Be careful with leaving spaces around too, as these will also cause problems.

Mike

javauser007
Champ in-the-making
Champ in-the-making

Hi Mike,
Good morning.
I did the changes according to ur suggesstions but still no luck.
The below is my web-scripts-config-custom.xml.

<engine label="Google Search" proxy="remote">

               <url type="application/atom+xml" >



               <url type="application/atom+xml">

                              http://www.google.co.in/search?hl=en&amp;q={searchTerms}&amp;btnG=Google+Search&amp;

                              meta=&amp;aq=f&amp;oq=

                         </url>

                         <url type="application/rss+xml">

                              http://www.google.co.in/search?hl=en&amp;q={searchTerms}&amp;btnG=Google+Search&amp;

                              meta=&amp;aq=f&amp;oq=

                         </url>





               </engine> 

the error i'm getting is

org.alfresco.config.ConfigException: Failed to parse config stream

        at org.alfresco.config.xml.XMLConfigService.parse(XMLConfigService.java:

177)

        at org.alfresco.config.BaseConfigService.appendConfig(BaseConfigService.

java:255)

        at org.alfresco.config.BaseConfigService.parse(BaseConfigService.java:28

5)

        at org.alfresco.config.xml.XMLConfigService.initConfig(XMLConfigService.

java:111)

        at org.alfresco.config.BaseConfigService.init(BaseConfigService.java:96)



        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:585)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1240)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1205)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

Factory.createBean(AbstractAutowireCapableBeanFactory.java:425)

        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb

ject(AbstractBeanFactory.java:251)

        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr

y.getSingleton(DefaultSingletonBeanRegistry.java:156)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:248)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:160)

        at org.springframework.beans.factory.support.DefaultListableBeanFactory.

getBeansOfType(DefaultListableBeanFactory.java:247)

        at org.springframework.context.support.AbstractApplicationContext.getBea

nsOfType(AbstractApplicationContext.java:796)

        at org.springframework.context.support.AbstractApplicationContext.regist

erListeners(AbstractApplicationContext.java:592)

        at org.springframework.context.support.AbstractApplicationContext.refres

h(AbstractApplicationContext.java:349)

        at org.springframework.web.context.ContextLoader.createWebApplicationCon

text(ContextLoader.java:244)

        at org.springframework.web.context.ContextLoader.initWebApplicationConte

xt(ContextLoader.java:187)

        at org.springframework.web.context.ContextLoaderListener.contextInitiali

zed(ContextLoaderListener.java:49)

        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex

t.java:3843)

        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4

342)

        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase

.java:791)

        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77

1)

        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)



        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav

a:926)

        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j

ava:889)

        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492

)

        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)

        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java

:311)

        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl

eSupport.java:117)

        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)



        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)

        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)



        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443

)

        at org.apache.catalina.core.StandardService.start(StandardService.java:5

16)

        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710

)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:585)

        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Caused by: org.dom4j.DocumentException: Error on line 98 of document  : The elem

ent type "url" must be terminated by the matching end-tag "</url>". Nested excep

tion: The element type "url" must be terminated by the matching end-tag "</url>"

.

        at org.dom4j.io.SAXReader.read(SAXReader.java:482)

        at org.dom4j.io.SAXReader.read(SAXReader.java:343)

        at org.alfresco.config.xml.XMLConfigService.parse(XMLConfigService.java:

144)

        ... 47 more

if i comment the above code everything working just fine including searching to another repositories.
any help in this.. I'm stucked here to move.. I want to search external sites from alfresco. like google. The related config files i did not found in wiki.

thanks for ur support.

Thank you very much for your time

javauser007
Champ in-the-making
Champ in-the-making
Hi Mike i'm just getting it work a bit. but it is showing some 500 error as a error msg box.

An error occured:
Failed to retrieve search results for 'Google Search':500 Internal Server Error

even for remote repository also i'm getting the same error.
An error occured:
Failed to retrieve search results for 'Remote Alfresco Repository':500 Internal Server Error

the following is my code in web-script-config-custom.xml
<!–                                                       –>
<!–  Example configuration of multiple OpenSearch engines –>
<!–                                                       –>

<alfresco-config>

   <config evaluator="string-compare" condition="OpenSearch">
      <opensearch>

         <engines>
        
            <!–                                                     –>
            <!–  Example: Registration of remote Alfresco Server    –>
            <!–                                                     –>

            <!–  TODO: Find/Replace [host] with server host name    –>
            <!–  TODO: Find/Replace [port] with server port number  –>
            <engine label="Remote Alfresco Repository" proxy="remote">
               <url type="application/atom+xml">
                 

            http://192.133.35.121:8080/alfresco/service/api/search/keyword.atom?q={searchTerms}&p={startPage?}&c...
           
            </url>
               <url type="application/rss+xml">
                  http://192.133.35.121:8080/alfresco/api/service/search/keyword.rss?q={searchTerms}&p={startPage?}&c=...
               </url>
            </engine>
           
            <!–                                                     –>
            <!–  Example: Registration of Alfresco's Open Talk Blog –>
            <!–                                                     –>
<!–

            <engine label="Alfresco Open Source Talk" proxy="opentalk">
               <url type="application/rss+xml">
                  http://blogs.alfresco.com/opentalk/os-query?s={searchTerms}&itemstart={startIndex?}&itempage={startP...?}
               </url>
            </engine>
   
–>         



    <engine label="Google Search" proxy="remote">
               <url type="application/atom+xml" />

         <url type="application/atom+xml">
                  http://www.google.co.in/search?hl=en&q={searchTerms}&btnG=Google+Search&meta=&aq=f&oq=
         </url>
   
         <url type="application/rss+xml">
                  http://www.google.co.in/search?hl=en&q={searchTerms}&btnG=Google+Search&meta=&aq=f&oq=
         </url>

    </engine> 

   
      

       </engines>

      </opensearch>
   </config>
     
</alfresco-config>


But now it is showing the "Google search" and "Remote Alfresco Repository" check boxes under open search. But not working.
Any idea on this.

Regards,
Jav

mikeh
Star Contributor
Star Contributor
Check that second URL - I think it might be wrong in the sample configuration file.

It needs to be /alfresco/service/api/…

Thanks,
Mike

javauser007
Champ in-the-making
Champ in-the-making
Hi Mike thanks for ur quick reply..
The remote repository is ok!! I want to search through the external sites like Google.
I'm stucked here. can u check this from ur machine by placing the "google search" code in ur web-script-config-custom.xml.
this my urgent requirement. i searched through google but came up with empty hands.

Any help is appriciated.

Regards,
Jav

mikeh
Star Contributor
Star Contributor
Why have you got an empty url element in the Google config?
<url type="application/atom+xml" />

Mike

javauser007
Champ in-the-making
Champ in-the-making
Hi Mike,
Thanks for ur patience,
even if after removing this "<url type="application/atom+xml" />" empty url , I'm getting the same problem.
Is it possible to search google from alfresco? or is there any limitation for this?
Why because i have read a cople of tutorials/wiki/forums but i didn't get any code snippet to configure google seacr/any other search engines. Instead of this they are telling just "it allows to search other sites".


Regards,
jav