Search for nodes that do not have a property

cancel
Showing results for 
Search instead for 
Did you mean: 
neilecker
Active Member II

Search for nodes that do not have a property

Jump to solution

I'd like to search for nodes that do not have a specific property from the Javascript Console using fts-alfresco.  Is this possible?  I've tried several variations such as ISNULL, ISUNSET.

In the following example, I'm trying to find nodes that do not have the custom property gry:documentNumber. 

var searchObj = {
     query: 'PATH:"/app:company_home/st:sites/cm:test-area/cm:documentLibrary/cm:Test//*" AND TYPE:"gry:content" AND ISNULL:"gry:documentNumber" AND -ASPECT:"rma:record"',
     language: 'fts-alfresco',
     page: {maxItems: 10}
}

Thanks,

Neil

1 Solution

Accepted Solutions
andy1
Senior Member

Re: Search for nodes that do not have a property

Jump to solution

Hi

The answer depends on exactly what you mean ..... Do you want to find...

  1. Nodes that do not have the property at all?
  2. Nodes that have a null value for the property?
  3. Nodes that have an empty string value for the property?
  4. Nodes that are unqueryable as they generate no full text search tokens?
  5. Multi-valued properties where any one of the values is null?
  6. Some combination of the above.

There are several fields in the index to support such queries and some groupings which you have tried ISNULL, ISUNSET etc. I suspect you are probably looking for .......

......    -EXISTS:"gry:documentNumber"

Via the public API you can also facet on the PROPERTIES field and get reports of which properties are set over the results of a query.

Andy

View solution in original post

5 Replies
andy1
Senior Member

Re: Search for nodes that do not have a property

Jump to solution

Hi

The answer depends on exactly what you mean ..... Do you want to find...

  1. Nodes that do not have the property at all?
  2. Nodes that have a null value for the property?
  3. Nodes that have an empty string value for the property?
  4. Nodes that are unqueryable as they generate no full text search tokens?
  5. Multi-valued properties where any one of the values is null?
  6. Some combination of the above.

There are several fields in the index to support such queries and some groupings which you have tried ISNULL, ISUNSET etc. I suspect you are probably looking for .......

......    -EXISTS:"gry:documentNumber"

Via the public API you can also facet on the PROPERTIES field and get reports of which properties are set over the results of a query.

Andy

neilecker
Active Member II

Re: Search for nodes that do not have a property

Jump to solution

Thanks Andy!

Your assumption was correct, the EXISTS is what I needed to find nodes that do not have a particular property.  Whatever resource I was looking at may have been old and didn't seem to have that option but I do see it listed here:  Search in fields | Alfresco Documentation 

So my query to find nodes of a certain type that did not have the property "gry:documentNumber" became the following:

var searchObj = {
     query: 'PATH:"/app:company_home/st:sites/cm:test-area/cm:documentLibrary/cm:Test//*" AND TYPE:"gry:content" AND -EXISTS:"gry:documentNumber" AND -ASPECT:"rma:record"',
     language: 'fts-alfresco'
}

Neil

Telmo
Member II

Re: Search for nodes that do not have a property

Jump to solution

So, this should be the correct way for searching for the different scenarios:

  1. Nodes that do not have the property at all?  -EXISTS:"gry:documentNumber"
  2. Nodes that have a null value for the property? ISNULL:"gry:documentNumber"
  3. Nodes that have an empty string value for the property? "gry:documentNumber":""

and if I want to combine all of them it should be

-EXISTS:"gry:documentNumber" OR ISNULL:"gry:documentNumber" OR "gry:documentNumber":""

Am I right?

Thanks.

 

EddieMay
Alfresco Employee

Re: Search for nodes that do not have a property

Jump to solution

Hi @Telmo 

Generally it is better to start a new thread rather than add to one where there is already an accepted solution - you are more likely to get a response with a new thread.

HTH,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
franciscoduarte
Member II

Re: Search for nodes that do not have a property

Jump to solution

Hi,

Is there a way to this with filterQueries ?

Something like "filterQueries:" [{"query:" "gry:documentNumber:null"}]

Thanks