in Alfresco

Alfresco Lucene tutorial

Alfresco has ability to contain information, documents and their metadata – we can say that holding data in structured and organized way is important but here is one thing that we can not live without and that is retrieving the information.

In this tutorial we are going to explain how to use lucene search and get nodes that you need in fast and easy.

In alfresco everything is a node, node can be of certain type, with aspects applied to it and can have number of properties. Nodes that have content are interesting too as we can search the content as well, limited to those nodes that can be converted to text.

Type Search

Syntax : TYPE:”{type name}”

Examples for searching folders

TYPE:"cm:folder"
TYPE:"{http://www.alfresco.org/model/content/1.0}folder"

Property Search

Syntax: @{prefix}\:{property Name}:”Value to match”

Examples:

@cm\:name:"Buyer"
@cm\:name:"Buy*"

Aspect Search

Syntax: ASPECT:”{aspect name}”

Examples:

ASPECT:"ab:invoice"
ASPECT:"{http://www.alfrescoblog.com/model/data/1.0}invoice"

Text Search

Syntact: TEXT:”query”

Examples:

TEXT:"about"
TEXT:"ab0*"

Path Search

Using the path search we can search for for example all nodes that are childs direct or not to defined folder. Lets see few examples.

  • To select folder test that is under Company Home use:
    PATH:"/app:company_home/cm:test"
  • All directly below folder test

    PATH:"/app:company_home/cm:test/*"
  • All nodes below folder test on any depth
    PATH:"/app:company_home/cm:test//*"
  • All nodes below folder test on any depth and include folder text
    PATH:"/app:company_home/cm:test//."

Search Combinations

This is great but it is not enough, we need search combinations. Node with certain type and name and so on.

Combinations are achieved using AND, OR and NOT keywords. Also there is a way for using ‘+’ and ‘-‘.

To match one or other

TEXT:"query"   @cm\:name:"Buy*
TEXT:"query" OR  @cm\:name:"Buy*

To match both

+TEXT:"query"   +@cm\:name:"Buy*
TEXT:"query" AND  @cm\:name:"Buy*

To match one attribute and not other

+ASPECT:"ab:invoice"  AND  -@cm\:description:"Buy*
ASPECT:"ab:invoice"  AND NOT -@cm\:description:"Buy*

To NOT match one criteria we can not put -@cm\:description:”Buy*, for this we must add one criteria to match and other not to match like so

 +TYPE:"sys:base"  -@cm\:description:"Buy*

 Summary

We have shown how to use Lucene and query your nodes, for any questions let us know, we will be happy to help.

 

 

 

 

 

 

Don't be shellfish...Tweet about this on TwitterShare on LinkedInShare on Google+Share on RedditShare on Facebook

Was this helpful ?