How to index null values in JSON documents?

Last updated 22, Mar 2024

Question

How to index null values in JSON documents?

Answer

Redis does not index null values, so searching for them is impossible. There are workarounds for JSON documents, though:

  • Store a label when null is meant, but that will be interpreted as null in a FT.SEARCH command. Any value works, like _null. Will work also on hash documents
  • Add a TAG field that is an array of all empty fields in the object. Example: "nulls":["exchange"]

References

Learn more about Redis tag fields.