-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for =
ContactQL operator on date and numeric fields
#224
Comments
For dates specifically we could use the precision of the operand as a way of allowing "day" specific queries. IE, if you say |
For numbers It should be straightforward enough to make goflow do comparisons with at most 5 decimal places of accuracy... I think that avoids having to add an error margin. For dates, we did have it that it was an error to use a value with time information: nyaruka/rapidpro#2453 but that job would now fall to the goflow parser if we want to maintain that behavior. Evaluation in python/goflow has been by converting a date to a range of UTC timestamps and then matching things in that range. Seems like that would work in ES too? |
It's amazing what we keep discovering! Yes, turns out the Mailroom side does support using a match query: Would be interesting to see if And sure enough it looks like we are doing the same kind of range thing on dates and So ya, maybe we just need to add |
Can confirm that |
I guess last open question is what is the parser doing with dates on the right hand side? Does that need to be only date-level accuracy? (that seems like a reasonable start) |
(oh see your comment about that, ok, then I think that's all we need) |
add != operator for numbers, dates, created_on, fixes #224
Queue welcome message event to be handle by mailroom
Remove no longer used contact/resolve endpoint
So looks like for numeric fields we are using a
scaled_float
with a scale factor of 10,000, so basically a Decimal with 5 digits of precision:https://github.com/nyaruka/rp-indexer/blob/master/indexer.go#L499
So should be fine for equality with the gotcha that non-elastic searching will need to evaluate equality to only 5 decimal places. (at least to my reading, we should try some queries to check)
https://www.elastic.co/guide/en/elasticsearch/reference/master/number.html
Dates are, well,
date
:https://www.elastic.co/guide/en/elasticsearch/reference/master/date.html
That said we probably want to play with these as I think perhaps you can only do
range
queries on both of these:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
Which doesn't support an
eq
operator. So I think we will need to rewrite these somehow to be anand
with agte
andlt
.For numbers I suppose we can just add the smallest value based on our precision (
.00001
) and for dates a second? Although I don't think we ever add dates without times set, thedate
field in Elastic does have time as optional so may need to figure out what comparison does between a date with a time set and one without.cc @rowanseymour
The text was updated successfully, but these errors were encountered: