Search for a model

You can use this command to search for models you’ve already created.

The response will contain only those model versions to which you have access. For example, if you send a match_all query, model versions for the following model group types will be returned:

  • All public model groups in the index
  • Private model groups for which you are the model owner
  • Model groups that share at least one backend role with your backend roles

For information about user access for this API, see Model access control considerations.

Path and HTTP methods

  1. GET /_plugins/_ml/models/_search
  2. POST /_plugins/_ml/models/_search

Example request: Searching for all models

  1. POST /_plugins/_ml/models/_search
  2. {
  3. "query": {
  4. "match_all": {}
  5. },
  6. "size": 1000
  7. }

copy

Example request: Searching for models with the algorithm “FIT_RCF”

  1. POST /_plugins/_ml/models/_search
  2. {
  3. "query": {
  4. "term": {
  5. "algorithm": {
  6. "value": "FIT_RCF"
  7. }
  8. }
  9. }
  10. }

copy

Example: Excluding model chunks

  1. GET /_plugins/_ml/models/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "must_not": {
  6. "exists": {
  7. "field": "chunk_number"
  8. }
  9. }
  10. }
  11. },
  12. "sort": [
  13. {
  14. "created_time": {
  15. "order": "desc"
  16. }
  17. }
  18. ]
  19. }

copy

Example: Searching for all model chunks

The following query searches for all chunks of the model with the ID 979y9YwBjWKCe6KgNGTm and sorts the chunks in ascending order:

  1. GET /_plugins/_ml/models/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "filter": [
  6. {
  7. "term": {
  8. "model_id": "9r9w9YwBjWKCe6KgyGST"
  9. }
  10. }
  11. ]
  12. }
  13. },
  14. "sort": [
  15. {
  16. "chunk_number": {
  17. "order": "asc"
  18. }
  19. }
  20. ]
  21. }

copy

Example: Searching for a model by description

  1. GET _plugins/_ml/models/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "should": [
  6. {
  7. "match": {
  8. "description": "sentence transformer"
  9. }
  10. }
  11. ],
  12. "must_not": {
  13. "exists": {
  14. "field": "chunk_number"
  15. }
  16. }
  17. }
  18. },
  19. "size": 1000
  20. }

copy

Example response

  1. {
  2. "took" : 8,
  3. "timed_out" : false,
  4. "_shards" : {
  5. "total" : 1,
  6. "successful" : 1,
  7. "skipped" : 0,
  8. "failed" : 0
  9. },
  10. "hits" : {
  11. "total" : {
  12. "value" : 2,
  13. "relation" : "eq"
  14. },
  15. "max_score" : 2.4159138,
  16. "hits" : [
  17. {
  18. "_index" : ".plugins-ml-model",
  19. "_id" : "-QkKJX8BvytMh9aUeuLD",
  20. "_version" : 1,
  21. "_seq_no" : 12,
  22. "_primary_term" : 15,
  23. "_score" : 2.4159138,
  24. "_source" : {
  25. "name" : "FIT_RCF",
  26. "version" : 1,
  27. "content" : "xxx",
  28. "algorithm" : "FIT_RCF"
  29. }
  30. },
  31. {
  32. "_index" : ".plugins-ml-model",
  33. "_id" : "OxkvHn8BNJ65KnIpck8x",
  34. "_version" : 1,
  35. "_seq_no" : 2,
  36. "_primary_term" : 8,
  37. "_score" : 2.4159138,
  38. "_source" : {
  39. "name" : "FIT_RCF",
  40. "version" : 1,
  41. "content" : "xxx",
  42. "algorithm" : "FIT_RCF"
  43. }
  44. }
  45. ]
  46. }
  47. }