Skip to content
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

[Bug]: The radius and range_filter parameters of searh in the Java SDK are not effective #38407

Open
1 task done
yongxin3344520 opened this issue Dec 12, 2024 · 5 comments
Open
1 task done
Assignees
Labels
kind/bug Issues or changes related a bug triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@yongxin3344520
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Environment

- Milvus version: v2.5.0-beta/v2.5.0-beta-gpu
- standalone  
- SDK version: java-2.5.0
- win10

Current Behavior

this is my part code :

Map<String, Object> stringObjectMap = searchParams(indexType) ;

    ((Map<String, Object>)stringObjectMap.get("params")).put("radius",  0.8);
    ((Map<String, Object>)stringObjectMap.get("params")).put("range_filter", 1.2f);

    SearchReq searchReq = SearchReq.builder()
            .data(data)
            .annsField(VECTOR_FIELD)
            .searchParams(stringObjectMap )
            .collectionName(collectionName)
            .partitionNames(selectParts.isEmpty() ? parts : new ArrayList<>(selectParts))
            .limit(Math.min(500, topK))
            .topK(Math.min(500, topK))
            .filter(ids.isEmpty() ? "" : (" id in [" + ids.toString() + "]"))
            .build();

    SearchResp searchResp = null ;

    MilvusClientV2 client = pool.getClient(key);

    // load
    client.loadCollection(LoadCollectionReq.builder().collectionName(collectionName).build());

    try {
        searchResp = client.search(searchReq);
    }catch (Exception e){
        log.error("", e);
    }finally {
        pool.returnClient(key, client);
    }

private Map<String, Object> searchParams(IndexParam.IndexType indexType){
Map<String, Object> objectMap = new HashMap<>();

    switch (indexType){
        case IndexParam.IndexType.IVF_PQ:
            objectMap.put("metric_type", "IP");
            Map<String, Object> param0 = new HashMap<>();
            param0.put("nprobe", 8);
            objectMap.put("params", param0);
            break;
        case IndexParam.IndexType.IVF_FLAT:
            objectMap.put("metric_type", "IP");
            Map<String, Object> param1 = new HashMap<>();
            param1.put("nprobe", 8);
            objectMap.put("params", param1);
            break;
        case IndexParam.IndexType.IVF_SQ8:
            objectMap.put("metric_type", "IP");
            Map<String, Object> param2 = new HashMap<>();
            param2.put("nprobe", 8);
            objectMap.put("params", param2);
            break;

        case IndexParam.IndexType.GPU_CAGRA:
            objectMap.put("metric_type", "IP");
            Map<String, Object> param3 = new HashMap<>();
            // param3.put("itopk_size", 128);
            objectMap.put("params", param3);
            break;

        case IndexParam.IndexType.GPU_IVF_FLAT:
            objectMap.put("metric_type", "IP");
            Map<String, Object> param4 = new HashMap<>();
            param4.put("nprobe", 8);
            objectMap.put("params", param4);
            break;

        case IndexParam.IndexType.GPU_IVF_PQ:
            objectMap.put("metric_type", "IP");
            objectMap.put("index_type", "GPU_IVF_PQ");
            Map<String, Object> param5 = new HashMap<>();
            param5.put("nprobe", 8);
            objectMap.put("params", param5);
            break;

        default:
            throw new RuntimeException("ERROR INDEX TYPE:"+indexType);
    }
    return objectMap;
}

Expected Behavior

The radius and range_filter parameters of sealh in the Java SDK are not effective, Those with similarity below the threshold were also queried.
Using Python is normal

Steps To Reproduce

No response

Milvus Log

No response

Anything else?

No response

@yongxin3344520 yongxin3344520 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 Dec 12, 2024
@xiaofan-luan
Copy link
Collaborator

I don't think GPU index support range search.

@liliu-z can you confirm?

@yongxin3344520
Copy link
Author

These two parameters work in both GPU and CPU versions using Python, but do not work in Java CPU and GPU versions

@xiaofan-luan
Copy link
Collaborator

@yanliang567
could you help on verify it?

@yanliang567
Copy link
Contributor

/assign @yongpengli-z
please help
/unassign

@yanliang567 yanliang567 added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 13, 2024
@yongpengli-z
Copy link
Contributor

This may be a problem,help confirm whether the method of passing parameters is correct @yhmo,Java-sdk search returns results, but python does not.
image
python 👇
range search:

default_search_params = {"metric_type": "IP", "params": {"nprobe": 10, "radius":0.8, "range_filter": 1.2}}
res = c.search(vectors[:nq], "fieldFloatVector", default_search_params, limit, "fieldInt64 >= 0")
res
data: ['[]']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Issues or changes related a bug triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

5 participants