Find the nearest neighbors to a provided search item
This API call allows you to query an entity for results which are the closest match to an image or text you provide to Graft through "entity_knn_adhoc" this can be a string or uri to an image of interest.
"entity_knn_adhoc": {"description":"The most delicious food"},
"entity_knn_adhoc": {"description":"The most delicious food"},
or"entity_knn_adhoc": {"cuisine":"modern italian"},
or
"entity_knn_adhoc": {"customer_rating":"above average"},
or"entity_knn_adhoc": {"description":"The most delicious food","cuisine":"modern italian","customer_rating":"above average"},
Sample Code
curl https://app.graft.com/v1/query -H 'Content-Type: application/json' -X POST -d '{
"secret": "SArh7qq.4q9vhmwgh17JAJ6EuhAlJJUYavhtXVgiRTabcmgS",
"organization": "<your_organization>",
"project": "my_project",
"output_format": "csv",
"entity": "MyEntity",
"embedding_name": "my_embedding",
"entity_columns": ["id", "data"],
"entity_knn_adhoc": {"<field to be searched>":"The most delicious food"},
"entity_knn_k": 10
}'
Simple Example
Please see REST API overview for the example values
"Find the 5 nearest matches to the provided speciality"
curl https://app.graft.com/v1/query -H 'Content-Type: application/json' -X POST -d '{
"secret": "somethingiamnotgoingtosaveingithub",
"organization": "supervillain",
"project": "world_domination",
"output_format": "csv",
"entity": "despicable_plan_1",
"embedding_name": "my_embedding",
"entity_columns": ["id", "name", "speciality", "number_of_films", "id_photo"],
"entity_knn_adhoc": {"minion_speciality":"various nefarious skills including stealth"},
"entity_knn_k": 5
}'