elastiknn icon indicating copy to clipboard operation
elastiknn copied to clipboard

A wrong query structure of hamming/jaccard space will trigger java.security.AccessControlException and the server will crash

Open liuyonghengheng opened this issue 6 months ago • 0 comments

Support guidelines

Background

step 1:

define a mapping with type elastiknn_sparse_bool_vector and use jaccard space

curl  -H'Content-Type: application/json'  -X  PUT  http://localhost:9200/my-vector-index -d '{
"mappings":{
    "properties": {
        "my_vec1": {
            "type": "elastiknn_sparse_bool_vector",
            "elastiknn": {
                "dims": 10, 
                "model": "lsh",
                "similarity": "jaccard",
                "L": 99,
                "k": 1
            }
        }
}
}}'

step2: using a wrong structure of vec:

curl -H'Content-Type: application/json' -X GET http://localhost:9200/my-vector-index/_search -d'{
    "query": {
        "elastiknn_nearest_neighbors": {        
            "field": "my_vec1", 
            "vec": {
                "values": [1,1,1,1,1,1,1,1,1,1]
            },
            "model": "lsh",
            "similarity": "jaccard",
            "candidates": 50
        }
    }
}'

then we should received a error response,but the node server crashed.

Bug

Image from the log we can find the reason:the function DenseFloat.toString call the class scala.reflect.ClassTag,but do not have the permission of getClassLoader.

Elastiknn Version

8.17.5.0

Platform

my laptop with system ubuntu22

Steps to reproduce

step 1:

define a mapping with type elastiknn_sparse_bool_vector and use jaccard space

curl  -H'Content-Type: application/json'  -X  PUT  http://localhost:9200/my-vector-index -d '{
"mappings":{
    "properties": {
        "my_vec1": {
            "type": "elastiknn_sparse_bool_vector",
            "elastiknn": {
                "dims": 10, 
                "model": "lsh",
                "similarity": "jaccard",
                "L": 99,
                "k": 1
            }
        }
}
}}'

step2: using a wrong structure of vec:

curl -H'Content-Type: application/json' -X GET http://localhost:9200/my-vector-index/_search -d'{
    "query": {
        "elastiknn_nearest_neighbors": {        
            "field": "my_vec1", 
            "vec": {
                "values": [1,1,1,1,1,1,1,1,1,1]
            },
            "model": "lsh",
            "similarity": "jaccard",
            "candidates": 50
        }
    }
}'

then we should received a error response,but the node server crashed.

Additional info

No response

liuyonghengheng avatar Jun 15 '25 03:06 liuyonghengheng