3

I have three documents, first: I have an empty images object, second: I have a null in images.front, and third: I have object in images.front.

As follows:

[{
  "images": {}
}, {
  "images": {
    "front": null
  }
}, { 
  "images": {
    "front": {
      "id": 1
    }
  }
}]

How can I search only for the documents that have front image (documents two and three, but not first)?

Many thanks :)

1 Answer 1

1

As far i know(i worked only till 1.7.2), document 1 and 2 will have same json structure in _source document of the elastic.As elasticsearch doesn't support null values.

So if you want to search for documents which have images , do a exists filters in the must bool filter.

elastic null values

Exists filter in elasticsearch

Sign up to request clarification or add additional context in comments.

4 Comments

so you say there is nothing i can do?
try to model your data in a different way , with array of image objects along with the count .
what is the difference? empty array will be the same as null and not exists.. elastic.co/guide/en/elasticsearch/reference/2.1/…
i'm know that i can change the model, but it's dirty.. if there is no other option i will change my model :( thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.