Developer forum

Forum » CMS - Standard features » Repository Query - matching nothing/empty string/null etc

Repository Query - matching nothing/empty string/null etc

Kevin Steffer
Reply

I have some News Items in a Repository where I what to get all News by Country (string[]) And Department (string[]) parameters (both).
But I also want all News Items from the Repository index by Country and where Department is not set (null, empty string) and by Department where Country is not set (null, empty string)
how is that possible?
Can I write my own Macro to match "nothing" or is there a trick with a Constant value?


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Kevin,

You cannot find documents based on an empty value. This is due to a limitation in Lucene where empty fields are not written. The solution is usually to represent an empty value with some sort of constant. For News documents that have a country/department, the fields would contain those values. For News documents where there are no country/department, you should put --NULL-- or some other value that you decide, but you can uniquely identify and does not colide with regular values for that field.

This needs to happen at index-time, as it's too late at query-time.

- Jeppe

 

You must be logged in to post in the forum