-
Notifications
You must be signed in to change notification settings - Fork 63
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
query params #152
base: master
Are you sure you want to change the base?
query params #152
Conversation
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.
What about supplying the parameters dict when executing a query (in Client.search or Client.aggregate)
So the parameter names are used in a query, and the query could be executed multiple times, each time with specific param values.
redisearch/query.py
Outdated
self._params = params | ||
return self | ||
|
||
def add_param(self, param_name:str, value:Union[str, int, float]): |
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.
It could also set a value for an existing param, no?
def add_param(self, param_name:str, value:Union[str, int, float]): | |
def set_param(self, param_name:str, value:Union[str, int, float]): |
@@ -532,8 +534,8 @@ def search(self, query): | |||
has_payload=query._with_payloads, | |||
with_scores=query._with_scores) | |||
|
|||
def explain(self, query): | |||
args, query_text = self._mk_query_args(query) | |||
def explain(self, query, query_params: Dict[str, Union[str, int, float]] = None): |
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.
Incompatible variable type: query_params is declared to have type Dict[str, Union[float, int, str]]
but is used as type None
.
(at-me in a reply with help
or ignore
)
test/test.py
Outdated
client.add_document('doc3', name='Carol') | ||
|
||
params_dict = {"name1":"Alice", "name2":"Bob"} | ||
q = Query("@name:($name1 | $name2 )").set_params_dict(params=params_dict) |
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 prefer to have something like:
params = {"name1":"Alice", "name2":"Bob"}
q = Query("@name:($name1 | $name2 )")
res1 = client.search(params=params)
res2 = client.search(params=other_params)
WDYT?
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.
we have it, continue reading the test ;)
redisearch/client.py
Outdated
if query_params is not None: | ||
args+= Query.get_params_args(query_params) |
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.
Do you want to use the member query._params
if argument query_params
is None
?
(or even to merge both if both are not None
, giving precedence to the argument over the member?)
Or do you want to get rid of the member? (it is only available for Query
, not for AggregateRequest
)
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.
LGTM 👍🏼
Kudos, SonarCloud Quality Gate passed!
|
Kudos, SonarCloud Quality Gate passed!
|
Should it also be supported in FT.PROFILE command? |
Should work, but not yet tested. |
Query params for
search
functionalitytested against
omer-query-params
branch