cancel
Showing results for 
Search instead for 
Did you mean: 

Search & Authentication

rogier_oudshoor
Champ in-the-making
Champ in-the-making
I am developing a community site based on alfresco webscripts. We have an issue with using search.

From what i've seen, when i use the search API from javascript, the search will return all items that the logged in user has access to.

However, when i use Java-based search (which i have to, because i want to order the results), i get all items … even the items the user does not have access to.

Is there a way to remove the results that the user does not have access to?
10 REPLIES 10

mikeh
Star Contributor
Star Contributor
(which i have to, because i want to order the results)
What problems are you having sorting the results in Javascript?

Mike

rogier_oudshoor
Champ in-the-making
Champ in-the-making
Well, when i look at the documentation (at http://wiki.alfresco.com/wiki/JavaScript_API#Search_API ), there is no way to sort the results except programmatically. Typically, a search may return hundreds of results … of which i'd only like to process the first 50 or so. Ordering by code would mean a huge overhead, which i'd like to avoid by having Lucene order the results.

If i can order & limit the results via JavaScript, i'd be quite happy  Smiley Very Happy

rogier_oudshoor
Champ in-the-making
Champ in-the-making
After a long search, i found what was causing this.

I was using spring beans to set the searchService to my own search implementation. The given searchService has admin access.

Alfresco's search implementation retrieves the searchService at runtime via the serviceRegistry. This searchService has the access of the current user.

This method appears to apply to all of Alfresco's services. Basically, if you want to do something that requires admin access, you can get the services directly from Spring. If you want to be restricted by the users' capabilities, you need to retrieve the services dynamically via the serviceRegistry.

Personally, i feel this is poor design - i'd be much happier if you could tell the service what kind of access you'd like to use. Any thoughts?

rraulji
Champ in-the-making
Champ in-the-making
Hi Rogier,

Did u find a way to sort and even restrict the number of results returned by Alfresco's Javascript API for search ?

rogier_oudshoor
Champ in-the-making
Champ in-the-making
Hi rraulji,

The only way to sort (as far as i know) is using the Java API. That means that, if you want to use call from Javascript, that you will have to code your own BaseScopableProcessorExtension to implement it.

Cheers,

Rogier

mikeh
Star Contributor
Star Contributor
From v2.9 the JavaScript search API supports sorting (added in SVN r1214 30-Oct-2007)
search.luceneSearch(query, sortColumn, sortAscending);

e.g. search.luceneSearch(query, "@cm:created", true);

Thanks,
Mike

satishvarmadand
Champ in-the-making
Champ in-the-making
Hi,
How can i incorporate detailed search in web-services API . I would like to incorporate
1) Sorting
2) Pagination like get search results from 1 -> 100 etc.. or give me only first 100 results etc.

Currently I am using something like this

Query query = new Query(Constants.QUERY_LANG_LUCENE, searchQuery);
QueryResult queryResult = WebServiceFactory.getRepositoryService().query(storeRef, query, false);

So how can i add "addSort" flag.

I found out that SearchParameters enables this. but webserice Repository service does not support this (only foundation repository service)

Also , while constructing the PATH query, how can i specify list of values
For Ex: PATH:"/app:company_home/cmSmiley Very HappyBM//*" AND  TEXT:"document"

so Instead of passing 1 value (document) for TEXT filed, how i can i pass array to values (instead of converting to OR and ANDs) for a specific meta-data field (which is multi-value attribute).

Any help would be greatly appreciated.

Thanks

t_broyer
Champ in-the-making
Champ in-the-making
After a long search, i found what was causing this.

I was using spring beans to set the searchService to my own search implementation. The given searchService has admin access.

Alfresco's search implementation retrieves the searchService at runtime via the serviceRegistry. This searchService has the access of the current user.

This method appears to apply to all of Alfresco's services. Basically, if you want to do something that requires admin access, you can get the services directly from Spring. If you want to be restricted by the users' capabilities, you need to retrieve the services dynamically via the serviceRegistry.

Personally, i feel this is poor design - i'd be much happier if you could tell the service what kind of access you'd like to use. Any thoughts?

Just use the "SearchService" rather than the "searchService". The "SearchService" is the one you'd get from the service registry, without the need for the service registry…

rogier_oudshoor
Champ in-the-making
Champ in-the-making
Just use the "SearchService" rather than the "searchService". The "SearchService" is the one you'd get from the service registry, without the need for the service registry…

Do you know if this holds true for all services? I.E., if there is a NodeService with ACL checking and a nodeService without it?