-
Notifications
You must be signed in to change notification settings - Fork 21
[WIP] Atlas search lookups #325
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
base: main
Are you sure you want to change the base?
Conversation
django_mongodb_backend/functions.py
Outdated
|
||
class SearchAutocomplete(SearchExpression): | ||
search_type = "autocomplete" | ||
expected_arguments = [("path", str), ("query", str)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected_arguments
pattern doesn't look nice to me. Is it doable to declare a separately __init__()
for each expression.
Also, I'm a bit doubtful we need strict checking of argument type. When we've added that sort of thing in Django, it's often caused problems due to the possibility of duck-typing.
django_mongodb_backend/functions.py
Outdated
@@ -268,6 +268,162 @@ def trunc_time(self, compiler, connection): | |||
} | |||
|
|||
|
|||
class SearchExpression(Expression): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are expressions rather than functions. Could you cherry-pick https://github.com/mongodb/django-mongodb-backend/compare/main...timgraham:move-expressions?expand=1 as the first commit of your branch and move these definitions to expressions/search.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the func
is defined as an expression and NumericMixin. This kind of function aren't combinable so I decided to part from expression and make a some similar to func
. In my point of view, it is a function 😄.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, it could be moved to expressions. A function is an expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested Expression since you inherited from it. I think the distinction between Expression and Func is more clear in SQL. Whichever you feel is most appropriate is probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expression is better, these aren't pure functions, they modify the state of the pipeline.
449b6a3
to
ca8a7cf
Compare
This PR adds the initial implementation of the Atlas operator.
Notes
While working on this, I found a few problems:
For example:
autocomplete
andequals
require a different type of index thanphrase
ortext
.Simplicity was preferred originally, but here we need to define field-level index types to support the required functionality.
Additionally, the way this implementation works gives us a preview of how
annotates
andfilter
queries will be added. They won't differ much from this one.