cancel
Showing results for 
Search instead for 
Did you mean: 

Searching by API

srowsell
Champ in-the-making
Champ in-the-making
I'm trying to find the best way to do a search of the repository, returning the result set in some form (preferably JSON), ideally using something like SQL to form the query.  Most of what I've been doing so far have just been Lucene searches in javascript, and while those were fine for some applications I need to be a little more fine-tuned in my queries.  Some examples, especially showing how to handle custom properties, would be fantastic.

In a similar vein I did some digging (using Firebug) and found a link like this:

http://alf01:8080/alfresco/s/slingshot/search?site=&term=&tag=&maxResults=251&sort=&query={'prop_sts...

and that does more or less return what I want it to return.  Some of the name=value pairs in the query string don't work as I would expect them to work; I don't know what the "site" or "sort" values should be to do anything, as the values I've put into them (such as known values for sites for the "site", or "asc" for "sort") don't have any effect on the result set.  Is there a resource to look at what these search properties are supposed to mean?

Thanks muchly,

Steve
4 REPLIES 4

kaynezhang
World-Class Innovator
World-Class Innovator
First be aware that the
http://alf01:8080/alfresco/s/slingshot/search
is a webscript api not javascript api .Event if it is implemented using javascript search api ,it dose some encapsulation on parameter name and parameter format.and also it's purpose is for share ,co contain some parameter like site.
In this
/slingshot/search
webscript api :

      site the site identifier to search into, null for all sites
      term: search terms
      tag: search tag
      query: advanced search query json
      sort: sort field ,it's format is like this sort fied|sort order,default sort order is asc ,for example:@cm:name|true,@cm:name,TYPE|false

I guess you want to do some field search using javascript search api ,it has different parameter name and parameter format ,here is an example

var sort1 =
{
  column: "@cm:modified",
  ascending: false
};

var sort2 =
{
  column: "@cm:name",
  ascending: true
};

var paging =
{
  maxItems: 20,
  skipCount: 0
};

var def =
{
  query: "+PATH:\"/app:company_home/cm:TESTFOLDER1//*\" +@cm\:title:\"banana\"",
  store: "workspace://SpacesStore",
  language: "fts-alfresco",
  sort: [sort1, sort2],
  page: paging
};

var results = search.query(def);

srowsell
Champ in-the-making
Champ in-the-making
I wasn't very clear on this, but my goal here isn't to use this in javascript (though I appreciate the code – that might be helpful elsewhere).  No, my goal is to either use the existing API or build my own, probably using Java, ideally (but not necessarily) using something more like SQL to do the query.  So if there are any tips for that, I'm still interested in trying them out.

As for the URI I quoted, perhaps I'm having trouble with mine.  You mentioned that (for example) the "site" term should narrow the search by site, but no matter what value I put into that term I get the same result set.  I can put a nonsense string of characters,a known site name, or nothing at all, and nothing changes.  The other terms in the query string work as expected, thanks.

Steve

kaynezhang
World-Class Innovator
World-Class Innovator
The reason why you get the same result set no matter what value you put into that term is you are using parameter
 repo=true 

When alfresco found this parameter ,it will search nodes under the rootnode you specified instead of search node under a site,the site parameter is just ignored.

If you want to use java and a sql lke query language,I suggest you use opencmis(chemistry) api and use cmis query langguage.

srowsell
Champ in-the-making
Champ in-the-making
Yes, that was what I was missing.

I'm also looking into OpenCMIS Chemistry, as it looks like I'll need it.

Thanks.