Skip to content

Search: Add completion suggest field to ai_questions mapping#3108

Closed
reakaleek wants to merge 1 commit intomainfrom
hail-cucumber
Closed

Search: Add completion suggest field to ai_questions mapping#3108
reakaleek wants to merge 1 commit intomainfrom
hail-cucumber

Conversation

@reakaleek
Copy link
Copy Markdown
Member

What

Add an FST-based completion type multi-field (ai_questions.suggest) to the ai_questions mapping for use with the completion suggester API.

Why

The existing ai_questions.completion multi-field is search_as_you_type (inverted index with shingles), which is incompatible with the completion suggester API. The completion suggester requires a field of type completion (FST).

How

Added a new suggest multi-field with Completion() type alongside the existing completion SearchAsYouType multi-field.

Test plan

  • Build compiles
  • Requires a crawler run to create new indices with the updated mapping

Notes

Named suggest since the completion multi-field name is already taken by SearchAsYouType.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@reakaleek reakaleek requested a review from a team as a code owner April 14, 2026 23:23
@reakaleek reakaleek requested a review from Mpdreamz April 14, 2026 23:23
@coderabbitai coderabbitai bot added the feature label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e341e078-943a-4457-bca5-a0c075b3e841

📥 Commits

Reviewing files that changed from the base of the PR and between 78603a9 and 6810eeb.

📒 Files selected for processing (1)
  • src/Elastic.Documentation/Search/DocumentationMappingConfig.cs

📝 Walkthrough

Walkthrough

The changes modify the Elasticsearch mapping configuration for the ai_questions field in DocumentationMappingConfig.cs. A syntax issue in the existing completion multi-field was corrected by removing an extraneous closing parenthesis. Additionally, a new suggest multi-field with completion capability was added to the ai_questions field, providing a separate completion sub-field alongside the existing search-as-you-type completion sub-field.

Suggested labels

feature

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a completion suggest field to the ai_questions mapping.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the what, why, how, and test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hail-cucumber

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

The search as you type is great if we have single autocomplete with mixed results and scoring. I believe we will bucket the results so question suggestions and doc suggestions are isolated from eachother. FST is great for that.

However other things become harder too, synonyms, partial (mid sentence words) starts, and scoring (weighting).

Approving we can play with this but I suspect we'd end up doing a search on the search_as_you type field instead.

reakaleek added a commit that referenced this pull request Apr 15, 2026
Add suggest completion multi-field to both ai_questions and
ai_autocomplete_questions, matching the approach in #3108.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@reakaleek reakaleek closed this Apr 15, 2026
@reakaleek
Copy link
Copy Markdown
Member Author

Will be handled in #3107

reakaleek added a commit that referenced this pull request Apr 15, 2026
* Search: Simplify ai_questions prompt for search-friendly output

The current prompt generates overly complex questions that don't match
real user search behavior. Redesign the prompt to produce shorter,
simpler questions (3-10 words) suitable for autocomplete and semantic
search — e.g. "What is agent builder?" instead of "How do I import
external tools using Model Context Protocol?"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Search: Fix contradictory guidance in ai_questions prompt

The prompt said "Avoid specific API names" but then used "What is the
bulk API?" as an example. Remove the API name restriction since we want
questions to reference feature/product names naturally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Search: Add ai_autocomplete_questions field with simplified prompt

Restore the original ai_questions prompt and add a new
ai_autocomplete_questions field with a prompt targeting short, simple
questions (3-10 words) suitable for search bar autocomplete. Includes
lexical mapping with SearchAsYouType completion multi-field and semantic
text mapping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Search: Add completion suggest multi-field to ai_questions mappings

Add suggest completion multi-field to both ai_questions and
ai_autocomplete_questions, matching the approach in #3108.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Search: Remove suggest multi-field from ai_questions mapping

Keep the suggest completion field only on ai_autocomplete_questions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants