cancel
Showing results for 
Search instead for 
Did you mean: 

Search using webservices API

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
3 REPLIES 3

pmonks
Star Contributor
Star Contributor
Multi-clause queries (such as 'PATH:"/app:company_home/cmSmiley Very HappyBM/*" AND TEXT:"document"') can be submitted via the query method (http://wiki.alfresco.com/wiki/Repository_Web_Service#query) just fine - check the docs for the "Query" parameter (http://wiki.alfresco.com/wiki/Web_Service_Data_Types#Query) for more details (in particular note that the query itself is just a string and can be any valid Lucene or XPath query).

Queries can also be batched (paged) via the use of a QueryHeader (http://wiki.alfresco.com/wiki/Web_Service_SOAP_Header#QueryHeader) in conjunction with the "fetchMore" method (http://wiki.alfresco.com/wiki/Repository_Web_Service#fetchMore).

It doesn't appear that sorting is exposed via the Web Services API, but that would be a good enhancement request (which can be raised at http://issues.alfresco.com/).

Cheers,
Peter

satishvarmadand
Champ in-the-making
Champ in-the-making
Hi Peter,
  Thanks for the reply. The problem with Query header is that it has only "fetchSize". So if you assign fetchSize as 100, then we can get back only first 100 search results. But there is no way in Query header to specify like i want results from 500-600 out of 1000 results. In other words, can we specify "start" & "end '"positions". This is required because if i want 5th page results (lets say there are 100 results per page), i could not able to find  a way to specify like i want search results from 500-600 instead of getting the complete result set ( I want to get only current subset instead of getting the entire set).

Is this possible.

Also, it seems there is a bug in Alfresco where getTotalResultsSize() always returns current fetchsize irrespective of total results count. I posted a query in WebService thread

http://forums.alfresco.com/en/viewtopic.php?f=27&t=15957

Any help would be greatly appreciated.

Thanks.
Satish

diegoboris
Champ in-the-making
Champ in-the-making
Hi!…
I´m new to ALfresco PHP Library, I have downloaded the version 2.1 from the wiki
and tried to run the Query Executer example but in vain.
(I'm running php 5.x)..
The problem I found was in the line ….foreach ($session->getStores() as $store)…..more
specifically in …$session->getStores()…it seems someone is getting hanged running it (be the
Apache or the RepositoryService)…though I got authenticated since I could print the session 's ticket..No errors are shown in the Alfresco and Apache logs.
The same happens when I try to access the CompanyHome via
$spacesStore = new SpacesStore($session);
// problem in here but no erros shown
$compHome = $spaceStore->getCompanyHome();
Could you give me a hand!!!!!
thanks