Query not returning null / field that does not exist


#1

I have a certain field which can be null, as I understand Elastic will not store this value anywhere in the Index since it is null.

However the problem I have is when doing a query and specifically a nested query I am not getting the desired results.

Take the below returned fields as an example:

           "attachments.id": [
              2,
              5,
              1,
              4,
              0,
              3
           ],
           "attachments.parentId": [
              2,
              1,
              0
           ]

The issue I face is that I can not match the attachments.ids with the parentIds. Only child attachments have a parent. If there was a way to return nulls or even a default value I would know which nodes are parent nodes (because their parentId would be null or -1).

I though I could achieve this by setting the "allow_null" value to -1 in the mapping for the attachments.parentId field but this did nothing...

To summarize I want to be able to say the parentId of this attachmentId is XX (whether that be 1,2,3 or -1).

Any suggestions?


(system) #2