Skip to content

[AI Assistant] Fixed DataClient find method to pass fields param to esClient.msearch#212465

Merged
YulNaumenko merged 7 commits intoelastic:mainfrom
YulNaumenko:fix-assistant-find-data-client-fields-select
Mar 3, 2025
Merged

[AI Assistant] Fixed DataClient find method to pass fields param to esClient.msearch#212465
YulNaumenko merged 7 commits intoelastic:mainfrom
YulNaumenko:fix-assistant-find-data-client-fields-select

Conversation

@YulNaumenko
Copy link
Copy Markdown
Contributor

@YulNaumenko YulNaumenko commented Feb 26, 2025

Fixed AIAssistantDataClient to send values of the fields param if is provided to esClient.msearch request.

To test run the API query http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId and makes sure the only provided fields are returned in the result.

@YulNaumenko YulNaumenko added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Feb 26, 2025
@YulNaumenko YulNaumenko self-assigned this Feb 26, 2025
@YulNaumenko YulNaumenko requested a review from a team as a code owner February 26, 2025 02:44
sortOrder: query.sort_order,
filter: query.filter,
fields: query.fields,
fields: query.fields ? transformFieldNamesToSourceScheme(query.fields) : undefined,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use _.snakeCase from lodash here?

case 'updatedBy':
return 'updated_by';
case 'timestamp':
return '@timestamp';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.youtube.com/watch?v=7W0EO6C2sFg

I think it's fine to do snakecase, but we do have some timestamp fields that do not use the @, for example the timestamp field in Message. I don't think we should be adjusting every timestamp field for this rason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I will drop timestamp and just use _.snakeCase from lodash

YulNaumenko and others added 4 commits February 28, 2025 14:37
…data-client-fields-select

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts
….com:YulNaumenko/kibana into fix-assistant-find-data-client-fields-select

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/server/routes/anonymization_fields/find_route.ts
#	x-pack/solutions/security/plugins/elastic_assistant/server/routes/knowledge_base/entries/find_route.ts
@stephmilovic
Copy link
Copy Markdown
Contributor

@elasticmachine merge upstream

@YulNaumenko YulNaumenko enabled auto-merge (squash) March 3, 2025 16:00
Comment on lines +75 to +77
_source: {
includes: fields,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_source: {
includes: fields,
},
_source: fields.length ? {
includes: fields,
} : true,

@YulNaumenko YulNaumenko merged commit 7afe813 into elastic:main Mar 3, 2025
9 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/13637026001

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @YulNaumenko

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 212465

Questions ?

Please refer to the Backport tool documentation

@stephmilovic
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

stephmilovic pushed a commit to stephmilovic/kibana that referenced this pull request Mar 3, 2025
…sClient.msearch (elastic#212465)

Fixed `AIAssistantDataClient` to send values of the `fields` param if is
provided to `esClient.msearch` request.

To test run the API query
`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`
and makes sure the only provided fields are returned in the result.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 7afe813)

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/server/ai_assistant_data_clients/find.ts
stephmilovic added a commit that referenced this pull request Mar 3, 2025
…m to esClient.msearch (#212465) (#212983)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[AI Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch
(#212465)](#212465)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Yuliia
Naumenko","email":"jo.naumenko@gmail.com"},"sourceCommit":{"committedDate":"2025-03-03T17:43:16Z","message":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch (#212465)\n\nFixed `AIAssistantDataClient` to send
values of the `fields` param if is\nprovided to `esClient.msearch`
request.\n\nTo test run the API
query\n`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`\nand
makes sure the only provided fields are returned in the
result.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7afe813b35ff4e1cd97be50dbaec2dec554eed26","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","backport:version","v9.1.0","v8.19.0"],"title":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch","number":212465,"url":"https://github.com/elastic/kibana/pull/212465","mergeCommit":{"message":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch (#212465)\n\nFixed `AIAssistantDataClient` to send
values of the `fields` param if is\nprovided to `esClient.msearch`
request.\n\nTo test run the API
query\n`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`\nand
makes sure the only provided fields are returned in the
result.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7afe813b35ff4e1cd97be50dbaec2dec554eed26"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212465","number":212465,"mergeCommit":{"message":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch (#212465)\n\nFixed `AIAssistantDataClient` to send
values of the `fields` param if is\nprovided to `esClient.msearch`
request.\n\nTo test run the API
query\n`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`\nand
makes sure the only provided fields are returned in the
result.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7afe813b35ff4e1cd97be50dbaec2dec554eed26"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Yuliia Naumenko <jo.naumenko@gmail.com>
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Mar 4, 2025
…m to esClient.msearch (elastic#212465) (elastic#212983)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[AI Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch
(elastic#212465)](elastic#212465)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Yuliia
Naumenko","email":"jo.naumenko@gmail.com"},"sourceCommit":{"committedDate":"2025-03-03T17:43:16Z","message":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch (elastic#212465)\n\nFixed `AIAssistantDataClient` to send
values of the `fields` param if is\nprovided to `esClient.msearch`
request.\n\nTo test run the API
query\n`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`\nand
makes sure the only provided fields are returned in the
result.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7afe813b35ff4e1cd97be50dbaec2dec554eed26","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","backport:version","v9.1.0","v8.19.0"],"title":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch","number":212465,"url":"https://github.com/elastic/kibana/pull/212465","mergeCommit":{"message":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch (elastic#212465)\n\nFixed `AIAssistantDataClient` to send
values of the `fields` param if is\nprovided to `esClient.msearch`
request.\n\nTo test run the API
query\n`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`\nand
makes sure the only provided fields are returned in the
result.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7afe813b35ff4e1cd97be50dbaec2dec554eed26"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212465","number":212465,"mergeCommit":{"message":"[AI
Assistant] Fixed DataClient find method to pass fields param to
esClient.msearch (elastic#212465)\n\nFixed `AIAssistantDataClient` to send
values of the `fields` param if is\nprovided to `esClient.msearch`
request.\n\nTo test run the API
query\n`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`\nand
makes sure the only provided fields are returned in the
result.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7afe813b35ff4e1cd97be50dbaec2dec554eed26"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Yuliia Naumenko <jo.naumenko@gmail.com>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…sClient.msearch (elastic#212465)

Fixed `AIAssistantDataClient` to send values of the `fields` param if is
provided to `esClient.msearch` request.

To test run the API query
`http://localhost:5601/api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=99&fields=id,users,apiConfig.connectorId`
and makes sure the only provided fields are returned in the result.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants