i'm trying to exclude objects which are deleted.. deleted_at is a datetime field and if the object is deleted it has a timestamp otherwise its nil.
this is my code:
tire.search(load: true, page: params[:page], per_page: 2) do
query { string params[:query], default_operator: "AND" } if params[:query].present?
filter :missing, field: :deleted_at
end
but this does exactly nothing on my output..
any hints?
So there are basically 3 states that a field/property could be in.
null
If I understand correctly you want docs where deleted_at
is in state 1 or 2. I think you need to create the equivalent of this:
"filter" : {
"missing" : {
"field" : "deleted_at",
"existence" : true,
"null_value" : true
}
}
The inner missing filter will find all docs which are in state 1 ( existence: true
) or state 2 ( null_value: true
).
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.