cancel
Showing results for 
Search instead for 
Did you mean: 

How to search the custom space using path query

srinivasan
Champ in-the-making
Champ in-the-making
Hi Developers,

I have created the custom space in the company home, the space name is ECM, inside ECM i have two more custom space ECM1 and ECM2.

I found the sample code for search in the firstfoundationclient.java which is given below.

SearchService searchService = serviceRegistry.getSearchService();
        StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
        ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home\"");        NodeRef companyHome = resultSet.getNodeRef(0);

here resultset size is 1

My code for search

SearchService searchService = serviceRegistry.getSearchService();
        StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
        ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/cm:ECM\"");
        //NodeRef companyHome = resultSet.getNodeRef(0);
        int size = resultSet.getChildAssocRefs().size();;
        System.out.println("size:"+size);

here resultset size is 0

but i have 2 subspaces under ECM Space.

In my query i gave the space name with case sensitive (i mean exact name like ECM not ecm). even though the result is zero.

Do you know why i am getting resultset size is 0 ?

or my search query is wrong?
5 REPLIES 5

andy
Champ on-the-rise
Champ on-the-rise
Hi

Yes, your search query is wrong…

Try



"PATH:\"/app:company_home/cm:ECM/*\""

See the search examples on the wiki.

http://wiki.alfresco.com/wiki/Search

Regards

Andy

srinivasan
Champ in-the-making
Champ in-the-making
Hi,


Thanks for your reply,

I followed your code but still i am getting the resultset size is 0 only.

Is this a right query?



Thanks

andy
Champ on-the-rise
Champ on-the-rise
Hi

It looks right to me, from what you have said
How did you create these nodes?

Try


"PATH:\"//cm:ECM\""

This should find cm:ECM anywhere in the repository ….

Regards

Andy

unknown-user
Champ on-the-rise
Champ on-the-rise
Hello there.

I have just read all these posts, and i have the same problem. I have tried all the options you say, and the size is = 0.

I have the following code:

SearchParameters sp = new SearchParameters();
sp.addStore(Repository.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
//sp.setQuery("PATH:\"/app:company_home/cm:service/cm:sub/*\"");
  sp.setQuery("PATH:\"//cm:sub\"");
ResultSet results = Repository.getServiceRegistry(context).getSearchService().query(sp);
List<NodeRef> listResults = results.getNodeRefs();

I have tried many options following the wiki document search, and listResults.size() = 0 in all of those cases.

Inside cm:sub, i have just a folder, which contains more folders, but it founds none of them.

Is that code correctly witten? or is there something wrong.

Thanks for your help and waiting for an answer
Bird

andy
Champ on-the-rise
Champ on-the-rise
Hi

Check the nodes and paths exist by following the the QNAME trail in the node browser (off the admin console) in the UI.

Does the user executing the query have permission to see the nodes?
If not, they do not come back in the search results.

So what are the permission settings on the thing you are trying to find and all of its parents?

Who is runing the query? What groups are they in?

Does a search for //* include the node you expect ?

Regards

Andy