Search for a model group

When you search for a model group, only those model groups to which you have access will be returned. For example, for a match all query, model groups that will be returned are:

  • All public model groups in the index
  • Private model groups for which you are the owner
  • Model groups that share at least one of the backend_roles with you

For more information, see Model access control.

Path and HTTP method

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

Example request: Match all

The following request is sent by user1 who has the IT and HR roles:

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

copy

Example response

  1. {
  2. "took": 31,
  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": 7,
  13. "relation": "eq"
  14. },
  15. "max_score": 1,
  16. "hits": [
  17. {
  18. "_index": ".plugins-ml-model-group",
  19. "_id": "TRqZfYgBD7s2oEFdvrQj",
  20. "_version": 1,
  21. "_seq_no": 2,
  22. "_primary_term": 1,
  23. "_score": 1,
  24. "_source": {
  25. "backend_roles": [
  26. "HR",
  27. "IT"
  28. ],
  29. "owner": {
  30. "backend_roles": [
  31. "HR",
  32. "IT"
  33. ],
  34. "custom_attribute_names": [],
  35. "roles": [
  36. "ml_full_access",
  37. "own_index",
  38. "test_ml"
  39. ],
  40. "name": "user1",
  41. "user_requested_tenant": "__user__"
  42. },
  43. "created_time": 1685734407714,
  44. "access": "restricted",
  45. "latest_version": 0,
  46. "last_updated_time": 1685734407714,
  47. "name": "model_group_test",
  48. "description": "This is an example description"
  49. }
  50. },
  51. {
  52. "_index": ".plugins-ml-model-group",
  53. "_id": "URqZfYgBD7s2oEFdyLTm",
  54. "_version": 1,
  55. "_seq_no": 3,
  56. "_primary_term": 1,
  57. "_score": 1,
  58. "_source": {
  59. "backend_roles": [
  60. "IT"
  61. ],
  62. "owner": {
  63. "backend_roles": [
  64. "HR",
  65. "IT"
  66. ],
  67. "custom_attribute_names": [],
  68. "roles": [
  69. "ml_full_access",
  70. "own_index",
  71. "test_ml"
  72. ],
  73. "name": "user1",
  74. "user_requested_tenant": "__user__"
  75. },
  76. "created_time": 1685734410470,
  77. "access": "restricted",
  78. "latest_version": 0,
  79. "last_updated_time": 1685734410470,
  80. "name": "model_group_test",
  81. "description": "This is an example description"
  82. }
  83. },
  84. ...
  85. ]
  86. }
  87. }

Example request: Search for model groups with an owner name

The following request to search for model groups of user is sent by user2 who has the IT backend role:

  1. GET /_plugins/_ml/model_groups/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "must": [
  6. {
  7. "nested": {
  8. "query": {
  9. "term": {
  10. "owner.name.keyword": {
  11. "value": "user1",
  12. "boost": 1
  13. }
  14. }
  15. },
  16. "path": "owner",
  17. "ignore_unmapped": false,
  18. "score_mode": "none",
  19. "boost": 1
  20. }
  21. }
  22. ]
  23. }
  24. }
  25. }

copy

Example response

  1. {
  2. "took": 6,
  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": 4,
  13. "relation": "eq"
  14. },
  15. "max_score": 0,
  16. "hits": [
  17. {
  18. "_index": ".plugins-ml-model-group",
  19. "_id": "TRqZfYgBD7s2oEFdvrQj",
  20. "_version": 1,
  21. "_seq_no": 2,
  22. "_primary_term": 1,
  23. "_score": 0,
  24. "_source": {
  25. "backend_roles": [
  26. "HR",
  27. "IT"
  28. ],
  29. "owner": {
  30. "backend_roles": [
  31. "HR",
  32. "IT"
  33. ],
  34. "custom_attribute_names": [],
  35. "roles": [
  36. "ml_full_access",
  37. "own_index",
  38. "test_ml"
  39. ],
  40. "name": "user1",
  41. "user_requested_tenant": "__user__"
  42. },
  43. "created_time": 1685734407714,
  44. "access": "restricted",
  45. "latest_version": 0,
  46. "last_updated_time": 1685734407714,
  47. "name": "model_group_test",
  48. "description": "This is an example description"
  49. }
  50. },
  51. ...
  52. ]
  53. }
  54. }

Example request: Search for model groups with a model group ID

  1. GET /_plugins/_ml/model_groups/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "must": [
  6. {
  7. "terms": {
  8. "_id": [
  9. "HyPNK4gBwNxGowI0AtDk"
  10. ]
  11. }
  12. }
  13. ]
  14. }
  15. }
  16. }

copy

Example response

  1. {
  2. "took": 2,
  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": 1,
  13. "relation": "eq"
  14. },
  15. "max_score": 1,
  16. "hits": [
  17. {
  18. "_index": ".plugins-ml-model-group",
  19. "_id": "HyPNK4gBwNxGowI0AtDk",
  20. "_version": 3,
  21. "_seq_no": 16,
  22. "_primary_term": 5,
  23. "_score": 1,
  24. "_source": {
  25. "backend_roles": [
  26. "IT"
  27. ],
  28. "owner": {
  29. "backend_roles": [
  30. "",
  31. "HR",
  32. "IT"
  33. ],
  34. "custom_attribute_names": [],
  35. "roles": [
  36. "ml_full_access",
  37. "own_index",
  38. "test-ml"
  39. ],
  40. "name": "user1",
  41. "user_requested_tenant": null
  42. },
  43. "created_time": 1684362035938,
  44. "latest_version": 2,
  45. "last_updated_time": 1684362571300,
  46. "name": "model_group_test",
  47. "description": "This is an example description"
  48. }
  49. }
  50. ]
  51. }
  52. }