Unfortunately this is not practical due to how indexes are stored. We use inverted indexes, which means that each term contains the list of documents which contain it. If we were to index the absence of a field, this would substantially inflate the index size and increase our indexing time, because every single field which may be empty but in the schema would need to be indexed with the implicit NULL value.
If you are concerned about a specific field being present, and if this is an option, perhaps a de-facto tag field, e.g. field_foo_empty.
I suppose this might also be possible using aggregations as well (although I don’t have this implemented, there are no needle-in-haystack limitations).
Mark Nunberg | Senior Software Engineer Redis Labs - home of Redis
Just to expand on what Mark has said as this pattern deserves an example, I’ve had to accomplish this previously and have used a tag field with tags to indicate emptiness.
Say you have 3 fields, foo, bar, and baz.
Then you’d have your schema like this:
FT.CREATE myindex
…
SCHEMA
foo TEXT
bar TEXT
baz TEXT
emptiness TAG
Then when you add a document with two of the fields empty, you would do:
OK, thanks for the clear answers. I am using tags now to indicate missing values, but I like the idea of having a dedicated tag field for that. That way, I can populate the field automatically at index time, and I know that only the indexer manages the contents of that field.