You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Alexandre Martins <al...@gmail.com> on 2007/03/23 13:22:45 UTC

Full-text Search in several workspaces

Hi all,

I need search something (full-text) in several workspaces, but i have a
problem. What a best way to perform this? Because i concat the results.
However, the last workspace will be their results in the end of my
collection. Make a sorting by jcr:score could be a good way?

below is my code,


StringBuffer strQuery = new StringBuffer();
            strQuery.append("SELECT * FROM nt:base WHERE CONTAINS(.,'"
                    + pTextQuery + "') ");
            if ((types != null) && (types.size() != 0)) {
                strQuery.append(" AND ( ");
                for (AssetTypeModel type : types) {
                    strQuery.append(" (jcr:mimeType='" + type.getMimeType()
                            + "') OR ");
                }
                strQuery.delete(strQuery.length() - 3, strQuery.length());
                strQuery.append(" ) ");
            }
            strQuery.append(" order by jcr:score DESC");
            Session session = null;
            try {
                for (WorkspaceModel workspace : workspaces) {
                    session = login(pRepository, pCredential, workspace
                            .getName());
                    QueryManager queryManager = session.getWorkspace()
                            .getQueryManager();
                    Query query = queryManager.createQuery(strQuery.toString
(),
                            Query.SQL);
                    QueryResult queryResult = query.execute();
                    NodeIterator iter = queryResult.getNodes();
                    while (iter.hasNext()) {
                        Node element = (Node) iter.next();
                        AssetModel asset = new AssetModel();
                        asset.setWorkspace(workspace);
                        asset.setName(element.getParent().getName());
                        asset.setPath(element.getParent().getPath());
                        asset.setSize(calculateSize(element.getProperty(
                        "jcr:data")));
                        lReturn.add(asset);
                    }
                }

            } catch (Exception e) {
                throw new BartEnvironmentException(getClass().getName(),
                        "findByNodeContentByWorkspaces", e);
            } finally {
                logoutSession(session);
            }

thanks,



-- 
Alexandre Costa Martins
CESAR - Recife Center for Advanced Studies and Systems
Software Engineer and Software Reuse Researcher
MSc Candidate at Federal University of Pernambuco
RiSE Member - http://www.rise.com.br

E-mail: alexandre.martins@cesar.org.br
MSN: xandecmartins@hotmail.com
GTalk: alexandremartins@gmail.com
Skype: xandecmartins
Mobile: +55 (81) 9929-9548
Office: +55 (81) 3425-4763
Fax: +55 (81) 3425-4701

Re: Full-text Search in several workspaces

Posted by David Nuescheler <da...@day.com>.
hi alexandre,

the workspace should not be regarded as a means of access control.
access control can be applied on an item level, so from an access control
perspective you should be able to keep "secret" information for multiple
parties within the same workspace.
so in general you could have a workspace W with a /samsung and a /motorola
section and apply access control on those folders, which would also be respected
by search or any other repository operation for that matter.

i believe you intuitively wanted to express an extra level of
separation by choosing
an individual workspace per "customer", which i think may be a good
right decision.
is it correct that searching across multiple workspaces or the entire
repository could be viewed as an exceptional case and as more of
an "admin" activity and the normal user would still only search
"their workspace"?

regards,
david

On 3/26/07, Alexandre Martins <al...@gmail.com> wrote:
> Hi David,
>
> Thanks for your answer.
> My problem is:
> Imagine that each workspace has stored top secret informations, as example,
> one workspace stores "Sansung" files and other workspace stores "Motorolla"
> files. Unfortunately, I can´t put these files in a unique workspace.
> But imagine that some users can access all workspaces (CEO as example),
> then, how can I make a search that return the results from all workspaces?
> After this, sorting by jcr:score (relevancy)...
>
> its my content model,
>
> Someone can help me?
>
> Regards,
>
> Alexandre Martins
>
> 2007/3/26, David Nuescheler <da...@gmail.com>:
> > hi alexandre,
> >
> > personally i would even go as far as saying that since the scope
> > of search is limited by definition to a "workspace" i would try to
> > avoid searching multiple workspaces.
> > usually, if you need to search multiple (or even "many") workspaces
> > it is an indication that the "workspace" metaphor was used in a
> > suboptimal way in the content model.
> >
> > i would much rather try to aggregate the information that
> > needs to be searched (possibly virtually) in a single workspace
> > that represents the scope of your search.
> > or is there a reason against that?
> >
> > maybe you could explain your content/data model and
> > the reasoning to split things into different workspaces.
> > since "content modelling" with jcr is fairly new for everybody
> > i think it would be interesting to share usecases and discuss them.
> >
> > regards,
> > david
> >
>
>
>
> --
> Alexandre Costa Martins
> CESAR - Recife Center for Advanced Studies and Systems
> Software Engineer and Software Reuse Researcher
> MSc Candidate at Federal University of Pernambuco
> RiSE Member - http://www.rise.com.br
>
> E-mail: alexandre.martins@cesar.org.br
> MSN: xandecmartins@hotmail.com
> GTalk: alexandremartins@gmail.com
> Skype: xandecmartins
> Mobile: +55 (81) 9929-9548
> Office: +55 (81) 3425-4763
> Fax: +55 (81) 3425-4701

Re: Full-text Search in several workspaces

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 3/26/07, Alexandre Martins <al...@gmail.com> wrote:
> Imagine that each workspace has stored top secret informations, as example,
> one workspace stores "Sansung" files and other workspace stores "Motorolla"
> files. Unfortunately, I can´t put these files in a unique workspace.
> But imagine that some users can access all workspaces (CEO as example),
> then, how can I make a search that return the results from all workspaces?
> After this, sorting by jcr:score (relevancy)...

I think your use case would be much better supported by setting the
access control policy within a single workspace than by using separate
workspaces (for which you in any case would control access).

For example, you could have the following content structure:

    /my:content
    /my:content/Samsung
    /my:content/Motorola

"Samsung people" would not have read access to /my:content/Motorola,
and "Motorola people" to /my:content/Samsung. Everyone could run
queries like /jcr:root/my:content//*[...] and only receive those
results to which they have read access. The "CEO" would have read
access everywhere, and would get results from both /my:content/Samsung
and /my:content/Motorola.

BR,

Jukka Zitting

Re: Full-text Search in several workspaces

Posted by Alexandre Martins <al...@gmail.com>.
Hi David,

Thanks for your answer.
My problem is:
Imagine that each workspace has stored top secret informations, as example,
one workspace stores "Sansung" files and other workspace stores "Motorolla"
files. Unfortunately, I can´t put these files in a unique workspace.
But imagine that some users can access all workspaces (CEO as example),
then, how can I make a search that return the results from all workspaces?
After this, sorting by jcr:score (relevancy)...

its my content model,

Someone can help me?

Regards,

Alexandre Martins

2007/3/26, David Nuescheler <da...@gmail.com>:
>
> hi alexandre,
>
> personally i would even go as far as saying that since the scope
> of search is limited by definition to a "workspace" i would try to
> avoid searching multiple workspaces.
> usually, if you need to search multiple (or even "many") workspaces
> it is an indication that the "workspace" metaphor was used in a
> suboptimal way in the content model.
>
> i would much rather try to aggregate the information that
> needs to be searched (possibly virtually) in a single workspace
> that represents the scope of your search.
> or is there a reason against that?
>
> maybe you could explain your content/data model and
> the reasoning to split things into different workspaces.
> since "content modelling" with jcr is fairly new for everybody
> i think it would be interesting to share usecases and discuss them.
>
> regards,
> david
>



-- 
Alexandre Costa Martins
CESAR - Recife Center for Advanced Studies and Systems
Software Engineer and Software Reuse Researcher
MSc Candidate at Federal University of Pernambuco
RiSE Member - http://www.rise.com.br

E-mail: alexandre.martins@cesar.org.br
MSN: xandecmartins@hotmail.com
GTalk: alexandremartins@gmail.com
Skype: xandecmartins
Mobile: +55 (81) 9929-9548
Office: +55 (81) 3425-4763
Fax: +55 (81) 3425-4701

Re: Full-text Search in several workspaces

Posted by David Nuescheler <da...@gmail.com>.
hi alexandre,

personally i would even go as far as saying that since the scope
of search is limited by definition to a "workspace" i would try to
avoid searching multiple workspaces.
usually, if you need to search multiple (or even "many") workspaces
it is an indication that the "workspace" metaphor was used in a
suboptimal way in the content model.

i would much rather try to aggregate the information that
needs to be searched (possibly virtually) in a single workspace
that represents the scope of your search.
or is there a reason against that?

maybe you could explain your content/data model and
the reasoning to split things into different workspaces.
since "content modelling" with jcr is fairly new for everybody
i think it would be interesting to share usecases and discuss them.

regards,
david

Re: Full-text Search in several workspaces

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Alexandre,

Alexandre Martins wrote:
> I need search something (full-text) in several workspaces, but i have a
> problem. What a best way to perform this? Because i concat the results.
> However, the last workspace will be their results in the end of my
> collection. Make a sorting by jcr:score could be a good way?

I'd say this depends on the query and the order by clause. You should do a merge 
sort on whatever column/property you have in the order by clause of the query.

regards
  marcel