This method conducts a vector query in a specified partition.
query(expr, output_fields=None, timeout=None, **kwargs)
Parameter | Description | Type | Required |
---|---|---|---|
expr | Boolean expression to filter the data | String | True |
output_fields | List of names of fields to output | list[String] | False |
timeout | An optional duration of time in seconds to allow for the RPC. If it is set to None, the client keeps waiting until the server responds or error occurs. | Float | False |
kwargs
|
|
| False |
A list that contains all results.
RpcError
: error if gRPC encounter an error.ParamError
: error if the parameters are invalid.BaseException
: error if the return result from server is not ok.from pymilvus import Partition
partition = Partition("novel")
res = collection.query(
expr = "book_id in [2,4,6,8]",
output_fields = ["book_id", "book_intro"],
consistency_level="Strong"
)
sorted_res = sorted(res, key=lambda k: k['book_id'])
sorted_res