1

I am writing a webscript, wherein I have a custom content model.

I want to list all the documents, that have a particular property as one of it's attributes.

Firstly I did

search.luceneSearch("PATH:\"/app:company_home//*\" AND @cm:name:myDocument")

This returned me value 1. But this query actually returns me the documents, whose cm:name property is myDocument.

what if I want to search for documents, who has cm:name property as an attribute.

So that later, I can change cm:name with mycontentmodel:myproperty, and find the elements that belong to my content type.

Kraken
  • 23,393
  • 37
  • 102
  • 162
  • possible duplicate of [Find all Lucene documents having a certain field](http://stackoverflow.com/questions/3710089/find-all-lucene-documents-having-a-certain-field) – Miki Oct 22 '14 at 11:15

1 Answers1

2

If I understand correctly, you'd like to find all the documents that have property mycontentmodel:myproperty, but you're not interested in the actual value of the property.

If so, find out what type or aspect mycontentmodel:myproperty belongs to.

If it belongs to type mycontentmodel:mytype the query can be:

PATH:"/app:company_home//*" AND TYPE:"mycontentmodel:mytype"

and if it belongs to aspect mycontentmodel:myaspect

PATH:"/app:company_home//*" AND ASPECT:"mycontentmodel:myaspect"
softwareloop
  • 383
  • 2
  • 5
  • Thanks for this. I have another question though, `cm` is a namespace right? And that namespace defines content of type `content`, `category`, `model`. so when I do cm:name, what exactly is name here? Is name a type/aspect or a property. If it is a property, what type/aspect does it belong to? – Kraken Oct 22 '14 at 10:07
  • @Kraken name is a property and it belongs to a cm namespace where cm is shorter for *content model* or if you want to know full namespace name -> `http://www.alfresco.org/model/content/1.0` – Miki Oct 22 '14 at 11:10
  • "cm" is defined in tomcat/webapps/alfresco/WEB-INF/classes/alfresco/model/contentModel.xml in your Alfresco installation. "cm:name" can be found in that file as a property of the "cm:cmobject" type. "cm:cmobject" is the parent type of "cm:folder", of "cm:content" and of other core types. – softwareloop Oct 23 '14 at 07:48