Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-7273

Autocomplete on search indexes should take into account embeddedDocuments

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Autocomplete
    • None
    • Developer Tools

      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:

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.mas@mongodb.com Kevin Mas Ruiz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: