[COMPASS-7273] Autocomplete on search indexes should take into account embeddedDocuments Created: 27/Sep/23  Updated: 15/Dec/23

Status: Needs Triage
Project: Compass
Component/s: Autocomplete
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Kevin Mas Ruiz Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Developer Tools

 Description   

When creating a Search index, you can't use the dot syntax to access to a field in an object inside an array. For example, take the following document into consideration:

{
   "movie": "Barbie",
   "topReviews": [
      { "score": 10, "review": "I'm just Ken" }
   ]
} 

If we want to create an index so we can search top reviews by text, it would be reasonable to try to define an index like this:

{
   "mappings": {
      "fields": {
         "topReviews.review": {
            "type": "string"
         }
      }
   }
} 

However, as review is an object inside an array of topReviews, this is not possible. We need to use the embeddedDocs type:

{
   "mappings": {
      "fields": {
         "topReviews": {
            "type": "embeddedDocument",            "fields": { "review": { "type": "string" } }
         }
      }
   }
} 

The autocomplete should be aware of the type of the document tree so it doesn't autocomplete with invalid index definitions.

More documentation:

 


Generated at Wed Feb 07 22:46:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.