Introduce Code Semantic Search API
What does this MR do and why?
In this issue, we will expose a Codebase Semantic Search API in Rails. This should make use of the same ActiveContext query class currently used by Classic Chat's Codebase Search Tool executor.
Add a new GraphQL API to expose the codebase query.
- This should have the following parameters:
user
search_term
-
[{ project_ids, path (optional) }]
(array) -
knn
- for theKNN_COUNT
-
limit
- for theSEARCH_RESULTS_LIMIT
- This should return an array of search results by the given
project_id|path
combination
References
ff: #568359 Related to #555843 (closed)
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
First follow the example to set up ES: !201128 (comment 2686596227)
enable the feature flag
[5] pry(main)> Feature.disabled?(:code_snippet_search_graphqlapi)
=> false
curl -X GET "http://localhost:9200/gitlab_active_context_code/_search?pretty" -H 'Content-Type: application/json' -d '{
"query": { "match_all": {} },
"size": 1000,
"track_total_hits": true
}'
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #555843 (closed)
Edited by Tian Gao