Search code examples
javaamazon-web-servicesfilteramazon-cloudsearch

Amazon Cloudsearch : Filter if exists


I have an amazon cloudsearch domain. The aim is to filter if the field 'language' exists. Not all objects have a language, and I want to have the ones which do have a language filtered, but the ones that do not have any language to also be returned.

I want to filter with ( or language:'en' language:null )

However, null cannot be passed within a string.

Is this possible? If so how would it be done.


Solution

  • I looked elsewhere aswell, it seems :

    The simplest way to do that, is to set a default value for the field, and then use that value for your null.

    For example, set the default to the string "null", then you can easily test for that.

    I believe you can add a default value, and re-index, and that should reapply the default.