- Notifications
You must be signed in to change notification settings - Fork590
-
Is it possible to evaluate multiple fields in a query and do math with the values in those fields to compare to a given value? For example, this is what I tried (unsuccessfully):
As I said, the above does not work, but I am hoping there is something similar that I can do. Specifically, I am trying to calculate the RMSE of three points and comparing that value to some error threshold. |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 2 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hey@pbhuter, I think you could use the defrms(doc):returnmath.sqrt(math.pow(doc['a']-a,2)+math.pow(doc['b']-b,2)+math.pow(doc['c']-c,2) )print(db.search(A.B.map(rms)<err)) That way you can also test that the Does that work for you? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hey@msiemens - Do you by any chance know how I should structure my search to access the 'a', 'b', 'c' in the following:
Where there are a total of 10 Points in several thousand objects (the "1" at the beginning is the first object). I am able to access "Pc" and "Pf", but if I try:
Thoughts? |
BetaWas this translation helpful?Give feedback.
All reactions
-
I think you could use the print(db.search(Point.Points.any(Point.a=='0.0690932185744956'))) Of course, you can combine this with the RMS query: defrms(doc):returnmath.sqrt(math.pow(doc['a'],2)+math.pow(doc['b'],2)+math.pow(doc['c'],2) )db=TinyDB('test.json')db.truncate()db.insert({"Pc":2429546524130460032,"Pf":2429519276857919232,"Points": [{"P":2428316170619108992,"a":0.0690932185744956,"b":2.6355498567408557,"c":0.4369495787854096}]})print(db.search(Query().Points.any(Query().map(rms)<3))) |
BetaWas this translation helpful?Give feedback.