0
votes

I am having some trouble with the autocomplete atlas search data type when trying to define an index for an array of subdocuments in my document.

My data structure for the documents in my collection looks like this:

{
   "data": {
     "equipment": {
       "entries": [
         {
           "name": "abcdefg"
         }
         {
           "name": "hijklmno"
         }
       ]
     }
   }
}

When I define a string index for searching the entries array, it works as intended and I get logical results. Here is my index definition using the lucene.keyword analyzer:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "data": {
        "fields": {
          "equipment": {
            "fields": {
              "entries": {
                "fields": {
                  "name": {
                    "analyzer": "lucene.keyword",
                    "searchAnalyzer": "lucene.keyword",
                    "type": "string"
                  }
                },
                "type": "document"
              }
            },
            "type": "document"
          }
        },
        "type": "document"
      }
    }
  }
}

However, when I try the same thing with the autocomplete type, I get an empty result, but no error. Here is how I defined the autocomplete:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "data": {
        "fields": {
          "equipment": {
            "fields": {
              "entries": {
                "fields": {
                  "name": {
                    "tokenization": "nGram",
                    "type": "autocomplete"
                  }
                },
                "type": "document"
              }
            },
            "type": "document"
          }
        },
        "type": "document"
      }
    }
  }
}

The documentation for Atlas Search states the following: The autocomplete type can't be used to index fields whose value is an array of strings. So either this sentence has to be changed to say all kinds of arrays or I am doing something wrong here. Can someone clarify if this is even possible? Thanks in Advance

1
Did you find an answer?Stone
@Stone not an answer for my original question, be we managed to build a workaround using normal string indices instead of ngram and queries utilising the wildcard feature.jakobn
@jakobn I'm running into the same problem, glad to see I'm not alone after struggling with it for a while. Can you share a little more about the approach you took for the workaround? Thanks!tajji

1 Answers

0
votes

Your syntax is completely wrong. its would be like:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "data.equipment.entries.name": [
        {
          "type": "autocomplete",
          "tokenization": "nGram",
          "minGrams": 3,
          "maxGrams": 7,
        }
      ]
    }
  }
}

But I am not sure that,if it support on array of document, But let me know if your problem is solved.