Query for field LIKE '' or "" returns nothing

Continuing the discussion from Aggregation: No bucket for empty field:

Enonic version: 6.8.0
OS: Linux

Could it be that Enonix XP/Elastic search does not index on empty string, undefined, null values?

Same with field = ‘’ and field = “”

These work:

NOT LIKE '*'
NOT LIKE "*"

Is there a IS EMPTY, or IS NOT TRUE expression?

Could not see it here:
http://xp.readthedocs.io/en/stable/reference/query-language.html

PostgreSQL:

ISNULL
https://www.postgresql.org/docs/current/static/functions-comparison.html

So I guess one should be able to distinguish between empty string and null aswell.

And consider the same for aggregations.

So without simplification that means 3 categories:

  • ISNULL
  • ISEMPTYSTRING
  • ISNULLOREMPTYSTRING

That might be a bit of an overkill for aggregations.

I guess quering on length is a complex idea?

field.length < 1

This did not work:

field < ' '

I was thinking less than the ASCII value of the space character.

There might be some ideas here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

This also does not work:

field IN ()

And gives:

500 Internal Server Error
Cannot build empty 'IN' statements (com.enonic.xp.resource.ResourceProblemException)

These does not work, not that they should:

field = null
field = undefined
field IN (null)
field IN (undefined)

Nope:

field IN ('')
field IN ("")

Could I write my own function? http://xp.readthedocs.io/en/stable/reference/query-language.html#functionexpr

This looks like a solution?
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/null-value.html

Better solution: https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-exists-query.html#_literal_missing_literal_query

I’ll use

NOT LIKE '*'

for queries.

As for aggregations I can estimate the ISEMPTY bucket docCount by doing something like this:

total - sum(buckets.docCount)

Yupp that works beautifully.

We have an “exists” - filter backend, but we are lacking in the js-api in this regard.
Stick with the not like for the moment, Ill create a task for better support of filter in the js-api’s.