Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: When querying for the maximum value of a certain field in Milvus, the returned value is not the maximum value #40561

Open
1 task done
tom729 opened this issue Mar 11, 2025 · 2 comments
Assignees
Labels
help wanted Extra attention is needed kind/bug Issues or changes related a bug

Comments

@tom729
Copy link

tom729 commented Mar 11, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Environment

- Milvus version:v2.5.4
- Deployment mode(standalone or cluster):standalone
- MQ type(rocksmq, pulsar or kafka):  no  
- SDK version(e.g. pymilvus v2.0.0rc2):
- OS(Ubuntu or CentOS): ubuntu
- CPU/Memory: 64G
- GPU: 24G
- Others:

Current Behavior

schema.add_field(field_name="image_id", datatype=DataType.INT64, is_primary=True, description="image id")
schema.add_field(field_name="image_info", datatype=DataType.JSON, description="image info")
schema.add_field(field_name="image_url", datatype=DataType.VARCHAR, max_length=500, description="image URL")
schema.add_field(field_name="image_vector", datatype=DataType.FLOAT_VECTOR, dim=512, description="image vector")
#schema.add_field(field_name="summary", datatype=DataType.VARCHAR, max_length=1000, description="work summary")
schema.add_field(field_name="summary_dense_vector", datatype=DataType.FLOAT_VECTOR, dim=1024, description="summary dense vector")
schema.add_field(field_name="summary_sparse_vector", datatype=DataType.SPARSE_FLOAT_VECTOR, description="summary sparse vector")

index_params = client.prepare_index_params()

index_params.add_index(
field_name="image_vector",
index_type="AUTOINDEX",
metric_type="IP",
)
index_params.add_index(
field_name="summary_dense_vector",
index_type="AUTOINDEX",
metric_type="IP",
)
index_params.add_index(
field_name="summary_sparse_vector",
index_type="SPARSE_INVERTED_INDEX",
metric_type="IP",
)
client.create_collection(
collection_name= my_collection_name,
schema=schema,
index_params=index_params,
)

search code:
result=client.query(
collection_name="total_text_image_search",
filter='',
output_fields=['image_id','image_info'],
limit=1,
order_by='image_id',
order ='DESC'
)
if result and len(result)>0:
max_image_id=result[0]['image_id']
max_work_id=result[0]['image_info']['work_id']

but the return value is not the max of the image_id.

Expected Behavior

No response

Steps To Reproduce

Milvus Log

No response

Anything else?

No response

@tom729 tom729 added kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 11, 2025
Copy link

dosubot bot commented Mar 11, 2025

@tom729 Hello there! I'm here to help you out with any bugs, questions, or contributions you have. Let's tackle this issue together!

The issue you're experiencing might be related to how the order_by and order parameters are functioning in your query. Unfortunately, I couldn't find specific information on the behavior or constraints of these parameters in Milvus v2.5.4. However, here are a few things you might want to check or try:

  1. Ensure Correct Field Usage: Verify that the order_by parameter is correctly set to the field you want to sort by, which in your case is image_id.

  2. Check Data Consistency: Ensure that the data in the image_id field is consistent and correctly indexed. Any inconsistencies might affect the query results.

  3. Query Logic: Double-check the logic of your query to ensure that it is correctly structured to retrieve the maximum value. You might want to test the query with different parameters or a smaller dataset to see if the issue persists.

  4. Milvus Documentation: Review the Milvus documentation for any updates or notes on the order_by and order parameters that might affect their behavior in version v2.5.4.

If these steps don't resolve the issue, consider testing with a different version of Milvus or checking for any updates or patches that might address this behavior.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@yanliang567
Copy link
Contributor

@tom729 order by is not supported in Milvus yet. BTW, Aggregation support is in the road map of milvus 2.6.x
/assign @tom729

@yanliang567 yanliang567 added help wanted Extra attention is needed and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 11, 2025
@yanliang567 yanliang567 removed their assignment Mar 11, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed kind/bug Issues or changes related a bug
Projects
None yet
Development

No branches or pull requests

2 participants