Hi! I am querying documents by date, and it works fine as long as there actually is a picked date at my custom field. I am using the dates to time limit a news post with both fromDate and toDate. I want to add the possibility for the editor to leave the date unpicked if there is no date limit. The problem is though that the date will then be null and wont be fetched within the date query (i am using dateAfter and dateBefore in my query). Is there a way for me to fetch documents that either is within the date limit OR has date = null ?
Hi @fredrik.bondeson, unfortunately I don’t think that you can do the query that you’re hoping to do in a single request as there isn’t an OR operator for something like this. I think that you’ll need to run two queries.
I can see why this would be an interesting thing to do, so I will let the @features-team know about this and we will add this to our feature request tracker as a possible improvement for the future. We don’t have any plans to work on this right now, but we will let you know here if that changes at any point.
Hey @fredrik.bondeson, I think you should be able to do that by combining your
dateAfter predicates and the
has predicates that are looking if there is any value in the field.
You can find the details here.
Let me know if that solves your issues