Skip to content

Search: Add ai_autocomplete_questions field for autocomplete#3107

Merged
reakaleek merged 5 commits intomainfrom
south-booth
Apr 15, 2026
Merged

Search: Add ai_autocomplete_questions field for autocomplete#3107
reakaleek merged 5 commits intomainfrom
south-booth

Conversation

@reakaleek
Copy link
Copy Markdown
Member

@reakaleek reakaleek commented Apr 14, 2026

What

Add a new ai_autocomplete_questions AI enrichment field with a prompt targeting short, simple questions for search bar autocomplete. Keep the existing ai_questions field unchanged.

Why

The existing ai_questions generates detailed technical questions (6-15 words) useful for semantic search, but too complex for autocomplete suggestions. Users searching naturally type simpler queries like "What is agent builder?" rather than "How do I import external tools using Model Context Protocol?"

How

  • Add AiAutocompleteQuestions property to DocumentationDocument with a prompt targeting 3-10 word questions
  • Add lexical mapping with SearchAsYouType completion and Completion suggest multi-fields
  • Add semantic text mapping for the new field
  • Add suggest completion multi-field to existing ai_questions mapping (per Search: Add completion suggest field to ai_questions mapping #3108)

Test plan

  • Verify build passes
  • Review generated questions after next AI enrichment run to confirm they are simpler and more natural

🤖 Generated with Claude Code

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>
@reakaleek reakaleek requested a review from a team as a code owner April 14, 2026 22:21
@reakaleek reakaleek requested a review from cotti April 14, 2026 22:21
@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: 9bcdb1f6-9c88-404c-931e-ed7a818dbaf3

📥 Commits

Reviewing files that changed from the base of the PR and between 36841d3 and ae36a5a.

📒 Files selected for processing (1)
  • src/Elastic.Documentation/Search/DocumentationMappingConfig.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Elastic.Documentation/Search/DocumentationMappingConfig.cs

📝 Walkthrough

Walkthrough

Added a new AI enrichment field AiAutocompleteQuestions to DocumentationDocument (type string[]?, JSON name ai_autocomplete_questions) decorated with [AiField(..., MinItems = 3, MaxItems = 5)], [Text], and [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]. Updated index mapping to include ai_autocomplete_questions in Lexical mappings with the synonyms_fixed_analyzer/synonyms_analyzer, plus two autocomplete-related multi-fields: a search_as_you_type subfield (with IndexOptions("offsets")) and a suggest completion subfield. Also added ai_autocomplete_questions.semantic_text to Semantic mappings. No other public signatures or runtime logic were changed.

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 and concisely summarizes the main change: adding the ai_autocomplete_questions field for autocomplete functionality.
Description check ✅ Passed The description is well-structured with clear What/Why/How sections that directly relate to the changeset and explain the rationale for the new field.

✏️ 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 south-booth

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Elastic.Documentation/Search/DocumentationDocument.cs`:
- Around line 150-151: The AiField attribute's prompt string on
DocumentationDocument is self-contradictory: it tells users to "Avoid jargon,
specific API names" but then includes the example "What is the bulk API?";
update the prompt in the AiField attribute to be consistent by either removing
the rule about avoiding specific API names or replacing the example with a
non-API-specific example (e.g., "What is bulk indexing?") so the guidance and
examples match; locate the AiField attribute text on the property in
DocumentationDocument and make the prompt and examples consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 92e1a1a3-4c37-4787-9226-32bf2338991b

📥 Commits

Reviewing files that changed from the base of the PR and between 78603a9 and 39349a6.

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

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>
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.

Should we have both? I feel the current will become super useful when we do more data/ai generated curation in the future.

reakaleek and others added 3 commits April 15, 2026 08:56
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>
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>
Keep the suggest completion field only on ai_autocomplete_questions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@reakaleek reakaleek changed the title Search: Simplify ai_questions prompt for autocomplete Search: Add ai_autocomplete_questions field for autocomplete Apr 15, 2026
@reakaleek reakaleek requested a review from Mpdreamz April 15, 2026 07:08
@reakaleek reakaleek merged commit e79528d into main Apr 15, 2026
30 checks passed
@reakaleek reakaleek deleted the south-booth branch April 15, 2026 07:25
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