Discussion:
[opencms-dev] How can search general in more perspective/multisite?
Deiverson Silveira
2014-10-01 11:24:21 UTC
Permalink
Hi List,

I have problem.

I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.

I stay perspective /sites/siteA/, dont see /sites/siteB/

My search don?t work because perspective, how can solved this problem?

I need help,

Regards,

Deiverson
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141001/2405131e/attachment.html>
fhsubscriptions
2014-10-01 11:57:51 UTC
Permalink
Hi Deiverson,

you can set the "parent sites" in the Solr query to enable search across
different sites.

Regards,

\Fabian
Post by Deiverson Silveira
Hi List,
I have problem.
I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/
My search don?t work because perspective, how can solved this problem?
I need help,
Regards,
Deiverson
--
/
/
/
/www.solutioncms.com <http://www.solutioncms.com>/
/
//
/
//
/The Brazilian //
//
/Official Provider OpenCms/
//
/
//
/
//
/
/
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141001/ce863096/attachment.html>
Deiverson Silveira
2014-10-03 18:53:40 UTC
Permalink
Hi Fabian,

Thank you for attention.

I don't use Solr, you know how can make this using Lucene? I use
traditional Lucene, I think this case is already a good opportunity to use
Solr and leave the Lucene.

I try set my object with project "/" but entry conflit in mysite because
perspective:

CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
and:
search.init(cmsproject);

Regards,

Deiverson

2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net <
Post by fhsubscriptions
Hi Deiverson,
you can set the "parent sites" in the Solr query to enable search across
different sites.
Regards,
\Fabian
Hi List,
I have problem.
I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/
My search don?t work because perspective, how can solved this problem?
I need help,
Regards,
Deiverson
--
* www.solutioncms.com <http://www.solutioncms.com> The Brazilian Official
Provider OpenCms *
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visithttp://lists.opencms.org/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141003/9d8f0ab9/attachment.html>
Schliemann, Kai
2014-10-06 09:21:05 UTC
Permalink
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to read the index you need. Or set it hard coded in your template, depending on the site you are in (not recommended).

HTH

Best regards
Kai

Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Deiverson Silveira
Gesendet: Freitag, 3. Oktober 2014 20:54
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Fabian,
Thank you for attention.

I don't use Solr, you know how can make this using Lucene? I use traditional Lucene, I think this case is already a good opportunity to use Solr and leave the Lucene.
I try set my object with project "/" but entry conflit in mysite because perspective:

CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
and:
search.init(cmsproject);

Regards,

Deiverson

2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net> <fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net>>:
Hi Deiverson,

you can set the "parent sites" in the Solr query to enable search across different sites.

Regards,

\Fabian

Am 01.10.2014 13:24, schrieb Deiverson Silveira:
Hi List,
I have problem.
I have multisites, and I have search general, I need search /sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/

My search don?t work because perspective, how can solved this problem?
I need help,
Regards,

Deiverson


--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms


_______________________________________________

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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev






--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141006/22a36a63/attachment.html>
Deiverson Silveira
2014-10-06 12:54:39 UTC
Permalink
Hi Kai,

But this way, for a global search on all subsites I would have to
instantiate each index and concatenate the results, right?

Regards,

Deiverson
Post by fhsubscriptions
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to
read the index you need. Or set it hard coded in your template, depending
on the site you are in (not recommended).
HTH
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Freitag, 3. Oktober 2014 20:54
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Fabian,
Thank you for attention.
I don't use Solr, you know how can make this using Lucene? I use
traditional Lucene, I think this case is already a good opportunity to use
Solr and leave the Lucene.
CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
search.init(cmsproject);
Regards,
Deiverson
2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net <
Hi Deiverson,
you can set the "parent sites" in the Solr query to enable search across different sites.
Regards,
\Fabian
Hi List,
I have problem.
I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/
My search don?t work because perspective, how can solved this problem?
I need help,
Regards,
Deiverson
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141006/e23930dc/attachment.html>
Schliemann, Kai
2014-10-06 14:02:49 UTC
Permalink
Hi Deiverson,
in this case you can use the method setSearchRoot(String searchRoot) of class CmsSearch to set a folder which should be used as root folder.
/**
* Convenience method to set exactly one search root.<p>
*
* @param searchRoot the search root to set
*
* @see #setSearchRoots(String[])
*/
public void setSearchRoot(String searchRoot) {

setSearchRoots(CmsStringUtil.splitAsArray(searchRoot, ","));
}

HTH
Best regards
Kai



Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Deiverson Silveira
Gesendet: Montag, 6. Oktober 2014 14:55
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,

But this way, for a global search on all subsites I would have to instantiate each index and concatenate the results, right?
Regards,

Deiverson

2014-10-06 6:21 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to read the index you need. Or set it hard coded in your template, depending on the site you are in (not recommended).

HTH

Best regards
Kai

Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Freitag, 3. Oktober 2014 20:54
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Fabian,
Thank you for attention.

I don't use Solr, you know how can make this using Lucene? I use traditional Lucene, I think this case is already a good opportunity to use Solr and leave the Lucene.
I try set my object with project "/" but entry conflit in mysite because perspective:

CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
and:
search.init(cmsproject);

Regards,

Deiverson

2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net> <fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net>>:
Hi Deiverson,

you can set the "parent sites" in the Solr query to enable search across different sites.

Regards,

\Fabian

Am 01.10.2014 13:24, schrieb Deiverson Silveira:
Hi List,
I have problem.
I have multisites, and I have search general, I need search /sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/

My search don?t work because perspective, how can solved this problem?
I need help,
Regards,

Deiverson


--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms


_______________________________________________

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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev





--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev






--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141006/7448738b/attachment.html>
Schliemann, Kai
2014-10-06 14:11:40 UTC
Permalink
Hi Deiverson,
for a global search you probably need this:

/**
* Sets the search root list.<p>
*
* Only resources that are sub-resources of one of the search roots
* are included in the search result.<p>
*
* The search roots set here are used <i>in addition to</i> the current site root
* of the user performing the search.<p>
*
* By default, the search roots contain only one entry with an empty string.<p>
*
* @param searchRoots the search roots to set
*/
public void setSearchRoots(String[] searchRoots) {

List<String> l = new ArrayList<String>(Arrays.asList(searchRoots));
m_parameters.setRoots(l);
resetLastResult();
}


Best regards
Kai

Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Deiverson Silveira
Gesendet: Montag, 6. Oktober 2014 14:55
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,

But this way, for a global search on all subsites I would have to instantiate each index and concatenate the results, right?
Regards,

Deiverson

2014-10-06 6:21 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to read the index you need. Or set it hard coded in your template, depending on the site you are in (not recommended).

HTH

Best regards
Kai

Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Freitag, 3. Oktober 2014 20:54
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Fabian,
Thank you for attention.

I don't use Solr, you know how can make this using Lucene? I use traditional Lucene, I think this case is already a good opportunity to use Solr and leave the Lucene.
I try set my object with project "/" but entry conflit in mysite because perspective:

CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
and:
search.init(cmsproject);

Regards,

Deiverson

2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net> <fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net>>:
Hi Deiverson,

you can set the "parent sites" in the Solr query to enable search across different sites.

Regards,

\Fabian

Am 01.10.2014 13:24, schrieb Deiverson Silveira:
Hi List,
I have problem.
I have multisites, and I have search general, I need search /sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/

My search don?t work because perspective, how can solved this problem?
I need help,
Regards,

Deiverson


--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms


_______________________________________________

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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev





--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev






--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141006/48adfab0/attachment.html>
Deiverson Silveira
2014-10-06 16:44:31 UTC
Permalink
Hi Kai,

I try setSearchRoots but problem with multisites, I dont see other
perspective.=/
I can /news/, /faq/, but my search dont see /sites/siteb/othernews/ for
exemplo, only one perspective.
I use setSearchRoots in jsp.

Regards,

Deiverson
Post by fhsubscriptions
Hi Deiverson,
/**
* Sets the search root list.<p>
*
* Only resources that are sub-resources of one of the search roots
* are included in the search result.<p>
*
* The search roots set here are used <i>in addition to</i> the current site root
* of the user performing the search.<p>
*
* By default, the search roots contain only one entry with an empty string.<p>
*
*/
*public* *void* setSearchRoots(String[] searchRoots) {
List<String> l = *new* ArrayList<String>(Arrays.*asList*(
searchRoots));
m_parameters.setRoots(l);
resetLastResult();
}
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Montag, 6. Oktober 2014 14:55
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Kai,
But this way, for a global search on all subsites I would have to
instantiate each index and concatenate the results, right?
Regards,
Deiverson
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to
read the index you need. Or set it hard coded in your template, depending
on the site you are in (not recommended).
HTH
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Freitag, 3. Oktober 2014 20:54
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Fabian,
Thank you for attention.
I don't use Solr, you know how can make this using Lucene? I use
traditional Lucene, I think this case is already a good opportunity to use
Solr and leave the Lucene.
CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
search.init(cmsproject);
Regards,
Deiverson
2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net <
Hi Deiverson,
you can set the "parent sites" in the Solr query to enable search across different sites.
Regards,
\Fabian
Hi List,
I have problem.
I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/
My search don?t work because perspective, how can solved this problem?
I need help,
Regards,
Deiverson
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141006/64d62704/attachment.html>
Schliemann, Kai
2014-10-06 17:30:05 UTC
Permalink
Hi Deiverson,
ok, too bad. I used that once in a project to distinguish between folders but within one site. I thought that would work with multi sites too.
Coming back to the index solution.
Is it possible for you to define three indices:

1. Index siteA

2. Index siteB

3. Index global
If someone does a global search (e.g. by ticking a checkbox ?global search?) you use that index. Otherwise you are using the site indices.
I think, this would be the easiest solution, if suitable for you.

Another approach, which needs changes in data structure:
Move all your news to the shared site and add categories to your news xsd. Categories would be ?siteA?, ?siteB?, ?global?.
Filter your search results by categories.
Only works, if your just want to search news content.

HTH
Best regards
Kai


Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Deiverson Silveira
Gesendet: Montag, 6. Oktober 2014 18:45
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,
I try setSearchRoots but problem with multisites, I dont see other perspective.=/
I can /news/, /faq/, but my search dont see /sites/siteb/othernews/ for exemplo, only one perspective.
I use setSearchRoots in jsp.

Regards,

Deiverson

2014-10-06 11:11 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
for a global search you probably need this:

/**
* Sets the search root list.<p>
*
* Only resources that are sub-resources of one of the search roots
* are included in the search result.<p>
*
* The search roots set here are used <i>in addition to</i> the current site root
* of the user performing the search.<p>
*
* By default, the search roots contain only one entry with an empty string.<p>
*
* @param searchRoots the search roots to set
*/
public void setSearchRoots(String[] searchRoots) {

List<String> l = new ArrayList<String>(Arrays.asList(searchRoots));
m_parameters.setRoots(l);
resetLastResult();
}


Best regards
Kai

Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Montag, 6. Oktober 2014 14:55
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,

But this way, for a global search on all subsites I would have to instantiate each index and concatenate the results, right?
Regards,

Deiverson

2014-10-06 6:21 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to read the index you need. Or set it hard coded in your template, depending on the site you are in (not recommended).

HTH

Best regards
Kai

Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Freitag, 3. Oktober 2014 20:54
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Fabian,
Thank you for attention.

I don't use Solr, you know how can make this using Lucene? I use traditional Lucene, I think this case is already a good opportunity to use Solr and leave the Lucene.
I try set my object with project "/" but entry conflit in mysite because perspective:

CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
and:
search.init(cmsproject);

Regards,

Deiverson

2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net> <fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net>>:
Hi Deiverson,

you can set the "parent sites" in the Solr query to enable search across different sites.

Regards,

\Fabian

Am 01.10.2014 13:24, schrieb Deiverson Silveira:
Hi List,
I have problem.
I have multisites, and I have search general, I need search /sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/

My search don?t work because perspective, how can solved this problem?
I need help,
Regards,

Deiverson


--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms


_______________________________________________

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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev




--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev





--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev






--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141006/01e1e0fb/attachment.html>
Deiverson Silveira
2014-10-07 12:36:02 UTC
Permalink
Hi Kai,

Success with this code, xD... see (sorry comment with portuguese), shared
and "viva o software livre":

<%@page import="org.opencms.file.CmsObject"%>
<%@page import="org.opencms.search.fields.CmsSearchFieldConfiguration"%>
<%@ page session="true" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="org.opencms.search.CmsSearchManager"%>
<%@page import="org.opencms.search.CmsSearchParameters"%>
<%@page import="org.opencms.main.OpenCms"%>
<%@page import="java.util.*"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.opencms.jsp.CmsJspActionElement"%>
<%@page import="org.opencms.search.CmsSearchResult"%>
<%@page import="org.opencms.search.*"%>
<%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
response);

//Criando o Objeto que ser? alternado via multisites
CmsObject obj = cms.getCmsObject();
//Seta o site do contexto atual para rollback
String siteRollBack =
OpenCms.getSiteManager().getDefaultSite().getSiteRoot();
//Setando os parametros de busca
CmsSearchParameters parametros = new CmsSearchParameters();
//Criando uma busca geral
CmsSearch searchGeral = new CmsSearch();
//Setando o indice de busca geral
parametros.setIndex("Offline project EN (VFS)");
//Passando o parametro de consulta, no exemplo abaixo busca por todo o
site
parametros.setParsedQuery("z* OR x* OR c* OR v* OR b* OR n* OR m* OR l*
OR k* OR j* OR h* OR g* OR f* OR d* OR s* OR a* OR q* OR w* OR e* OR r* OR
t* OR y* OR u* OR i* OR o* OR p*");
//Setando resultados por pagina
parametros.setMatchesPerPage(99999);
//Setando os parametros para a busca geral
searchGeral.setParameters(parametros);
//Preparando a lista de Resultados de Busca Geral
List<CmsSearchResult> listaResultado = null;
//Criando a lista de todos os multisites que ser?o iterados,
dinamicamente
Set<String> listaSites = OpenCms.getSiteManager().getSiteRoots();

//Realizando a itera??o de todos os multisites existentes
Iterator i = listaSites.iterator();
while(i.hasNext()){
//Nesse momento ? identificado um dos sites da lista existente
String multiSite = i.next().toString();
//Definindo o site raiz, referente a outra perspectiva
obj.getRequestContext().setSiteRoot(multiSite);
//Setando o objeto de busca geral com o objeto instanciado
anteriormente
searchGeral.init(obj);
//Se for a primeira itera??o, o objeto ser? null ao tentar
adicionar a lista de resultados concatenando, portanto foi necessario
adicionar o else
//para ser adicionado na primeira iteracao uma lista de resultado
if(listaResultado != null){
listaResultado.addAll(searchGeral.getSearchResult());
}else{
listaResultado = searchGeral.getSearchResult();
}
}
//Setando o site corrente de modo rollBack
obj.getRequestContext().setSiteRoot(siteRollBack);

//Exibindo o resultado da busca geral, que foi agregado de todos os
multisites
for(Iterator iterator = listaResultado.iterator(); iterator.hasNext();)
{
CmsSearchResult result = (CmsSearchResult)iterator.next();
out.println(result.getPath() + "<br>");
}
%>

Thank you for Fabian and Kai!

Success!

Deiverson
Post by fhsubscriptions
Hi Deiverson,
ok, too bad. I used that once in a project to distinguish between folders
but within one site. I thought that would work with multi sites too.
Coming back to the index solution.
1. Index siteA
2. Index siteB
3. Index global
If someone does a global search (e.g. by ticking a checkbox ?global
search?) you use that index. Otherwise you are using the site indices.
I think, this would be the easiest solution, if suitable for you.
Move all your news to the shared site and add categories to your news xsd.
Categories would be ?siteA?, ?siteB?, ?global?.
Filter your search results by categories.
Only works, if your just want to search news content.
HTH
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Montag, 6. Oktober 2014 18:45
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Kai,
I try setSearchRoots but problem with multisites, I dont see other perspective.=/
I can /news/, /faq/, but my search dont see /sites/siteb/othernews/ for
exemplo, only one perspective.
I use setSearchRoots in jsp.
Regards,
Deiverson
Hi Deiverson,
/**
* Sets the search root list.<p>
*
* Only resources that are sub-resources of one of the search roots
* are included in the search result.<p>
*
* The search roots set here are used <i>in addition to</i> the current site root
* of the user performing the search.<p>
*
* By default, the search roots contain only one entry with an empty string.<p>
*
*/
*public* *void* setSearchRoots(String[] searchRoots) {
List<String> l = *new* ArrayList<String>(Arrays.*asList*(
searchRoots));
m_parameters.setRoots(l);
resetLastResult();
}
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Montag, 6. Oktober 2014 14:55
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Kai,
But this way, for a global search on all subsites I would have to
instantiate each index and concatenate the results, right?
Regards,
Deiverson
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to
read the index you need. Or set it hard coded in your template, depending
on the site you are in (not recommended).
HTH
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Freitag, 3. Oktober 2014 20:54
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Fabian,
Thank you for attention.
I don't use Solr, you know how can make this using Lucene? I use
traditional Lucene, I think this case is already a good opportunity to use
Solr and leave the Lucene.
CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
search.init(cmsproject);
Regards,
Deiverson
2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net <
Hi Deiverson,
you can set the "parent sites" in the Solr query to enable search across different sites.
Regards,
\Fabian
Hi List,
I have problem.
I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/
My search don?t work because perspective, how can solved this problem?
I need help,
Regards,
Deiverson
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141007/e561d8cf/attachment.html>
Schliemann, Kai
2014-10-07 15:40:55 UTC
Permalink
Hi Deiverson,
glad, that you found a solution.
I would say most of the magic is the while loop below this comment ?//Realizando a itera??o de todos os multisites existentes?.

What I do not understand is, what the following line is needed for:
parametros.setParsedQuery("z* OR x* OR c* OR v* OR b* OR n* OR m* OR l* OR k* OR j* OR h* OR g* OR f* OR d* OR s* OR a* OR q* OR w* OR e* OR r* OR t* OR y* OR u* OR i* OR o* OR p*");
Additionally this looks to me like some kind of a performance killer, when this query is really executed with each search request.

But never mind. It works and that is important.

Best regards
Kai

Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Deiverson Silveira
Gesendet: Dienstag, 7. Oktober 2014 14:36
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,
Success with this code, xD... see (sorry comment with portuguese), shared and "viva o software livre":

<%@page import="org.opencms.file.CmsObject"%<mailto:%25 at page%20import=%22org.opencms.file.CmsObject%22%25>>
<%@page import="org.opencms.search.fields.CmsSearchFieldConfiguration"%<mailto:%25 at page%20import=%22org.opencms.search.fields.CmsSearchFieldConfiguration%22%25>>
<%@ page session="true" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="org.opencms.search.CmsSearchManager"%<mailto:%25 at page%20import=%22org.opencms.search.CmsSearchManager%22%25>>
<%@page import="org.opencms.search.CmsSearchParameters"%<mailto:%25 at page%20import=%22org.opencms.search.CmsSearchParameters%22%25>>
<%@page import="org.opencms.main.OpenCms"%<mailto:%25 at page%20import=%22org.opencms.main.OpenCms%22%25>>
<%@page import="java.util.*"%<mailto:%25 at page%20import=%22java.util.*%22%25>>
<%@page import="java.util.ArrayList"%<mailto:%25 at page%20import=%22java.util.ArrayList%22%25>>
<%@page import="org.opencms.jsp.CmsJspActionElement"%<mailto:%25 at page%20import=%22org.opencms.jsp.CmsJspActionElement%22%25>>
<%@page import="org.opencms.search.CmsSearchResult"%<mailto:%25 at page%20import=%22org.opencms.search.CmsSearchResult%22%25>>
<%@page import="org.opencms.search.*"%<mailto:%25 at page%20import=%22org.opencms.search.*%22%25>>
<%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);

//Criando o Objeto que ser? alternado via multisites
CmsObject obj = cms.getCmsObject();
//Seta o site do contexto atual para rollback
String siteRollBack = OpenCms.getSiteManager().getDefaultSite().getSiteRoot();
//Setando os parametros de busca
CmsSearchParameters parametros = new CmsSearchParameters();
//Criando uma busca geral
CmsSearch searchGeral = new CmsSearch();
//Setando o indice de busca geral
parametros.setIndex("Offline project EN (VFS)");
//Passando o parametro de consulta, no exemplo abaixo busca por todo o site
parametros.setParsedQuery("z* OR x* OR c* OR v* OR b* OR n* OR m* OR l* OR k* OR j* OR h* OR g* OR f* OR d* OR s* OR a* OR q* OR w* OR e* OR r* OR t* OR y* OR u* OR i* OR o* OR p*");
//Setando resultados por pagina
parametros.setMatchesPerPage(99999);
//Setando os parametros para a busca geral
searchGeral.setParameters(parametros);
//Preparando a lista de Resultados de Busca Geral
List<CmsSearchResult> listaResultado = null;
//Criando a lista de todos os multisites que ser?o iterados, dinamicamente
Set<String> listaSites = OpenCms.getSiteManager().getSiteRoots();

//Realizando a itera??o de todos os multisites existentes
Iterator i = listaSites.iterator();
while(i.hasNext()){
//Nesse momento ? identificado um dos sites da lista existente
String multiSite = i.next().toString();
//Definindo o site raiz, referente a outra perspectiva
obj.getRequestContext().setSiteRoot(multiSite);
//Setando o objeto de busca geral com o objeto instanciado anteriormente
searchGeral.init(obj);
//Se for a primeira itera??o, o objeto ser? null ao tentar adicionar a lista de resultados concatenando, portanto foi necessario adicionar o else
//para ser adicionado na primeira iteracao uma lista de resultado
if(listaResultado != null){
listaResultado.addAll(searchGeral.getSearchResult());
}else{
listaResultado = searchGeral.getSearchResult();
}
}
//Setando o site corrente de modo rollBack
obj.getRequestContext().setSiteRoot(siteRollBack);

//Exibindo o resultado da busca geral, que foi agregado de todos os multisites
for(Iterator iterator = listaResultado.iterator(); iterator.hasNext();)
{
CmsSearchResult result = (CmsSearchResult)iterator.next();
out.println(result.getPath() + "<br>");
}
%>
Thank you for Fabian and Kai!
Success!

Deiverson


2014-10-06 14:30 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
ok, too bad. I used that once in a project to distinguish between folders but within one site. I thought that would work with multi sites too.
Coming back to the index solution.
Is it possible for you to define three indices:

1. Index siteA

2. Index siteB

3. Index global
If someone does a global search (e.g. by ticking a checkbox ?global search?) you use that index. Otherwise you are using the site indices.
I think, this would be the easiest solution, if suitable for you.

Another approach, which needs changes in data structure:
Move all your news to the shared site and add categories to your news xsd. Categories would be ?siteA?, ?siteB?, ?global?.
Filter your search results by categories.
Only works, if your just want to search news content.

HTH
Best regards
Kai


Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Montag, 6. Oktober 2014 18:45

An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,
I try setSearchRoots but problem with multisites, I dont see other perspective.=/
I can /news/, /faq/, but my search dont see /sites/siteb/othernews/ for exemplo, only one perspective.
I use setSearchRoots in jsp.

Regards,

Deiverson

2014-10-06 11:11 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
for a global search you probably need this:

/**
* Sets the search root list.<p>
*
* Only resources that are sub-resources of one of the search roots
* are included in the search result.<p>
*
* The search roots set here are used <i>in addition to</i> the current site root
* of the user performing the search.<p>
*
* By default, the search roots contain only one entry with an empty string.<p>
*
* @param searchRoots the search roots to set
*/
public void setSearchRoots(String[] searchRoots) {

List<String> l = new ArrayList<String>(Arrays.asList(searchRoots));
m_parameters.setRoots(l);
resetLastResult();
}


Best regards
Kai

Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Montag, 6. Oktober 2014 14:55
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Kai,

But this way, for a global search on all subsites I would have to instantiate each index and concatenate the results, right?
Regards,

Deiverson

2014-10-06 6:21 GMT-03:00 Schliemann, Kai <K.Schliemann at comundus.com<mailto:K.Schliemann at comundus.com>>:
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to read the index you need. Or set it hard coded in your template, depending on the site you are in (not recommended).

HTH

Best regards
Kai

Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von Deiverson Silveira
Gesendet: Freitag, 3. Oktober 2014 20:54
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] How can search general in more perspective/multisite?

Hi Fabian,
Thank you for attention.

I don't use Solr, you know how can make this using Lucene? I use traditional Lucene, I think this case is already a good opportunity to use Solr and leave the Lucene.
I try set my object with project "/" but entry conflit in mysite because perspective:

CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
and:
search.init(cmsproject);

Regards,

Deiverson

2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net> <fhsubscriptions at componio.net<mailto:fhsubscriptions at componio.net>>:
Hi Deiverson,

you can set the "parent sites" in the Solr query to enable search across different sites.

Regards,

\Fabian

Am 01.10.2014 13:24, schrieb Deiverson Silveira:
Hi List,
I have problem.
I have multisites, and I have search general, I need search /sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/

My search don?t work because perspective, how can solved this problem?
I need help,
Regards,

Deiverson


--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms


_______________________________________________

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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev



--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev




--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev





--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms

_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev






--
www.solutioncms.com<http://www.solutioncms.com>
The Brazilian
Official Provider OpenCms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141007/fc464733/attachment.html>
Deiverson Silveira
2014-10-13 19:55:34 UTC
Permalink
Hi experts opencmsman?s,

I have problem now, I dont access contentload other perspective for example:

*for*(*Iterator* iterator = listaResultado.iterator(); iterator.hasNext();){

CmsSearchResult result = (CmsSearchResult)iterator.next();

out.println("result = " + result.getPath() + "<br>");

String pathRecurso = result.getPath();

pathRecurso = pathRecurso.substring(7, pathRecurso.length());

pathRecurso = pathRecurso.substring(pathRecurso.indexOf("/"),
pathRecurso.length());

CmsJspXmlContentBean contentBean = *new*
CmsJspXmlContentBean(cms.getJspContext(), cms.getRequest(),
cms.getResponse());

*for*(CmsJspTagContentLoad contentList =
(CmsJspTagContentLoad)contentBean.contentload("singleFile", pathRecurso,
*false*); contentList.hasMoreResources();){

*if*(contentBean.contentshow(contentList,"Titulo").length() >
0 && !contentBean.contentshow(contentList,"Titulo").startsWith("???")){

out.println("titulo = " +
contentBean.contentshow(contentList,"Titulo"));

}

}

%>

<cms:contentload collector=*"singleFile"* param=*"*<%=pathRecurso%>
*"* editable=*"false"*>

<cms:contentcheck ifexists=*"Titulo"*>

<c:set var=*"tituloNoticia"*><cms:contentshow element=
*"Titulo"* locale=*"*${locale}*"*/></c:set>

</cms:contentcheck>

${tituloNoticia}

</cms:contentload>

<%}%>

I belive my problem is this:
CmsJspXmlContentBean contentBean = *new*
CmsJspXmlContentBean(cms.getJspContext(), cms.getRequest(),
cms.getResponse());

I set current context, and no other context in other perspective =[, very
sad.

I debug opencms, stay way change permission in CmsSecurityManager, function
readResource.
Somebody idea more simple for I read contentload in other content other
perspective?

How can I see content in other perspective? What class I use for this?

Thank you for help,

Deiverson
Post by fhsubscriptions
Hi Deiverson,
glad, that you found a solution.
I would say most of the magic is the while loop below this comment
?//Realizando a itera??o de todos os multisites existentes?.
parametros.setParsedQuery("z* OR x* OR c* OR v* OR b* OR n* OR m* OR l* OR
k* OR j* OR h* OR g* OR f* OR d* OR s* OR a* OR q* OR w* OR e* OR r* OR t*
OR y* OR u* OR i* OR o* OR p*");
Additionally this looks to me like some kind of a performance killer, when
this query is really executed with each search request.
But never mind. It works and that is important.
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Dienstag, 7. Oktober 2014 14:36
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Kai,
Success with this code, xD... see (sorry comment with portuguese), shared
<%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
//Criando o Objeto que ser? alternado via multisites
CmsObject obj = cms.getCmsObject();
//Seta o site do contexto atual para rollback
String siteRollBack =
OpenCms.getSiteManager().getDefaultSite().getSiteRoot();
//Setando os parametros de busca
CmsSearchParameters parametros = new CmsSearchParameters();
//Criando uma busca geral
CmsSearch searchGeral = new CmsSearch();
//Setando o indice de busca geral
parametros.setIndex("Offline project EN (VFS)");
//Passando o parametro de consulta, no exemplo abaixo busca por todo o site
parametros.setParsedQuery("z* OR x* OR c* OR v* OR b* OR n* OR m* OR
l* OR k* OR j* OR h* OR g* OR f* OR d* OR s* OR a* OR q* OR w* OR e* OR r*
OR t* OR y* OR u* OR i* OR o* OR p*");
//Setando resultados por pagina
parametros.setMatchesPerPage(99999);
//Setando os parametros para a busca geral
searchGeral.setParameters(parametros);
//Preparando a lista de Resultados de Busca Geral
List<CmsSearchResult> listaResultado = null;
//Criando a lista de todos os multisites que ser?o iterados, dinamicamente
Set<String> listaSites = OpenCms.getSiteManager().getSiteRoots();
//Realizando a itera??o de todos os multisites existentes
Iterator i = listaSites.iterator();
while(i.hasNext()){
//Nesse momento ? identificado um dos sites da lista existente
String multiSite = i.next().toString();
//Definindo o site raiz, referente a outra perspectiva
obj.getRequestContext().setSiteRoot(multiSite);
//Setando o objeto de busca geral com o objeto instanciado anteriormente
searchGeral.init(obj);
//Se for a primeira itera??o, o objeto ser? null ao tentar
adicionar a lista de resultados concatenando, portanto foi necessario
adicionar o else
//para ser adicionado na primeira iteracao uma lista de resultado
if(listaResultado != null){
listaResultado.addAll(searchGeral.getSearchResult());
}else{
listaResultado = searchGeral.getSearchResult();
}
}
//Setando o site corrente de modo rollBack
obj.getRequestContext().setSiteRoot(siteRollBack);
//Exibindo o resultado da busca geral, que foi agregado de todos os multisites
for(Iterator iterator = listaResultado.iterator(); iterator.hasNext();)
{
CmsSearchResult result = (CmsSearchResult)iterator.next();
out.println(result.getPath() + "<br>");
}
%>
Thank you for Fabian and Kai!
Success!
Deiverson
Hi Deiverson,
ok, too bad. I used that once in a project to distinguish between folders
but within one site. I thought that would work with multi sites too.
Coming back to the index solution.
1. Index siteA
2. Index siteB
3. Index global
If someone does a global search (e.g. by ticking a checkbox ?global
search?) you use that index. Otherwise you are using the site indices.
I think, this would be the easiest solution, if suitable for you.
Move all your news to the shared site and add categories to your news xsd.
Categories would be ?siteA?, ?siteB?, ?global?.
Filter your search results by categories.
Only works, if your just want to search news content.
HTH
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Montag, 6. Oktober 2014 18:45
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Kai,
I try setSearchRoots but problem with multisites, I dont see other perspective.=/
I can /news/, /faq/, but my search dont see /sites/siteb/othernews/ for
exemplo, only one perspective.
I use setSearchRoots in jsp.
Regards,
Deiverson
Hi Deiverson,
/**
* Sets the search root list.<p>
*
* Only resources that are sub-resources of one of the search roots
* are included in the search result.<p>
*
* The search roots set here are used <i>in addition to</i> the current site root
* of the user performing the search.<p>
*
* By default, the search roots contain only one entry with an empty string.<p>
*
*/
*public* *void* setSearchRoots(String[] searchRoots) {
List<String> l = *new* ArrayList<String>(Arrays.*asList*(
searchRoots));
m_parameters.setRoots(l);
resetLastResult();
}
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Montag, 6. Oktober 2014 14:55
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Kai,
But this way, for a global search on all subsites I would have to
instantiate each index and concatenate the results, right?
Regards,
Deiverson
Hi Deiverson,
if you are using Lucene, you can create an index for each site.
And then set the index in your search JSP.
e.g. like
org.opencms.search.CmsSearch.setIndex(indexName);
AFAIK OpenCms provides a property ?search.index?. You could use that to
read the index you need. Or set it hard coded in your template, depending
on the site you are in (not recommended).
HTH
Best regards
Kai
opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
*Gesendet:* Freitag, 3. Oktober 2014 20:54
*An:* The OpenCms mailing list
*Betreff:* Re: [opencms-dev] How can search general in more
perspective/multisite?
Hi Fabian,
Thank you for attention.
I don't use Solr, you know how can make this using Lucene? I use
traditional Lucene, I think this case is already a good opportunity to use
Solr and leave the Lucene.
CmsObject cmsObject = cms.getCmsObject();
CmsProject cmsproject = cmsObject.readProject("Offline");
cmsObject.getRequestContext().setCurrentProject(cmsproject);
cmsObject.getRequestContext().setSiteRoot("/");
search.init(cmsproject);
Regards,
Deiverson
2014-10-01 8:57 GMT-03:00 fhsubscriptions at componio.net <
Hi Deiverson,
you can set the "parent sites" in the Solr query to enable search across different sites.
Regards,
\Fabian
Hi List,
I have problem.
I have multisites, and I have search general, I need search
/sites/siteA/news/ and /sites/siteB/news/.
I stay perspective /sites/siteA/, dont see /sites/siteB/
My search don?t work because perspective, how can solved this problem?
I need help,
Regards,
Deiverson
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>*
*The Brazilian *
*Official Provider OpenCms*
_______________________________________________
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/cgi-bin/mailman/listinfo/opencms-dev
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141013/af868834/attachment.html>
Loading...