cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to search for files based on the content model properties Rest API

Abhishek-S
Champ on-the-rise
Champ on-the-rise

Hello Community,

I'm trying to implement searching of files based on the properties of the content model of the document. 

I found this ReST API: 

GET /alfresco/s/slingshot/search?term={term?}&tag={tag?}&site={site?}&container={container?}&sort={sort?}&query={query?}&repo={repo?}

But I'm not sure how to pass the property name of the document in the query parameter.

For ex:

My docuemt content model is: dc:InvoiceModel

Property name is: dc:doctype.

So, I want to pass the dc:doctype as query parameter to fetch all the documents of this property type. The documents are inside a folder in the documentLibrary

I tried doing this:

http://localhost:8080/alfresco/s/slingshot/search?container=documentLibrary/newfolder&sort=dc:dc:doc...false&repo=true&startIndex=0&query={"dc:doctype":"Sales Invoice","datatype":"d:text"}

But I'm getting zero records found. Could you please help me do this.

Alfresco Version:
 
Alfresco Share v5.1.f
(r125711-b6, Aikau 1.0.63, Spring Surf 5.1.f, Spring WebScripts 6.5, Freemarker 2.3.20-alfresco-patched, Rhino 1.7R4-alfresco-patched, Yui 2.9.0-alfresco-20141223)
 
Alfresco Community v5.1.0
(r127059-b7) schema 10001
 
Thank you all!
1 ACCEPTED ANSWER

Take a look at this example: https://documenter.getpostman.com/view/2694867/SVfRuTWU#b9df9ccc-b76a-c7e6-e50e-0e926d7ff124

You need to also encode the values for sort and query. 

example:

dc:doctype|false TO dc%3Adoctype%7Cfalse

You can't use the colon in the query. Rather you should use the property name like: "prop_dc_doctype". see example here: https://documenter.getpostman.com/view/2694867/SVfRuTWU#b9df9ccc-b76a-c7e6-e50e-0e926d7ff124

datatype refers to the content/node type. e.g: cm:content not property data types like d:text.

You may have to set the tokenize property to "both"

<index enabled="true">
  <atomic>true</atomic>
  <stored>false</stored>
  <tokenised>both</tokenised>
</index>

Since you are using model manager, you need to set the indexing property to "Pattern - Many Matches". 

You should rather deploy the model via bootstapping to better control over model.

Take a look at these docs:

http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html

https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/content-model/#definedeploy

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View answer in original post

4 REPLIES 4

abhinavmishra14
World-Class Innovator
World-Class Innovator

Can you share the model where you have defined the propeties?

You can also review this doc: https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/content-model/

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Sir,

This is my Alfresco version: Alfresco Community v5.1.0

image

This is my custom defined model!

Take a look at this example: https://documenter.getpostman.com/view/2694867/SVfRuTWU#b9df9ccc-b76a-c7e6-e50e-0e926d7ff124

You need to also encode the values for sort and query. 

example:

dc:doctype|false TO dc%3Adoctype%7Cfalse

You can't use the colon in the query. Rather you should use the property name like: "prop_dc_doctype". see example here: https://documenter.getpostman.com/view/2694867/SVfRuTWU#b9df9ccc-b76a-c7e6-e50e-0e926d7ff124

datatype refers to the content/node type. e.g: cm:content not property data types like d:text.

You may have to set the tokenize property to "both"

<index enabled="true">
  <atomic>true</atomic>
  <stored>false</stored>
  <tokenised>both</tokenised>
</index>

Since you are using model manager, you need to set the indexing property to "Pattern - Many Matches". 

You should rather deploy the model via bootstapping to better control over model.

Take a look at these docs:

http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html

https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/content-model/#definedeploy

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Thanks sir, got it!