Are stringFacets supported inside embeddedDocuments?

I need to facet on fields within a collection of documents. For example, mappings look like this:

 "items": {
        "dynamic": false,
        "fields": {
          "position": {
            "type": "stringFacet"
        "type": "embeddedDocuments"

When creating these mappings I’m getting error:

Your index could not be built: Unexpected error: Field must have either TokenStream, String, Reader or Number value; got SortedSetDocValuesFacetField

Are stringFacets not supported inside embeddedDocuments?

This is happening because of the text Index defined over the field/document.

Error is coming from Lucene.

MongoDB Atlas Search is a full-text search feature that is built on top of Lucene.

Thanks Anuj,

I’m aware it’s built on Lucene and that’s the source of the underlying error. However, according to the documents this should work. The docs note numeric and date facets are NOT supported on embeddedDocuments, but does not mention incompatibility with stringFacet.

I need to know if stringFacet is also NOT supported and is accidentally omitted by the documentation, or if there is something wrong or missing in my syntax to get it working.

The error you are getting is because you are trying to create a stringFacet on a field that is an embedded document. MongoDB Atlas does not support faceting on embedded documents.

I’m attempting the stringFacet on a field within an embeddedDocument.

The limitiations state:

  • You can’t use embeddedDocuments for date or numeric faceting.

But fail to mention string faceting if this is indeed ALSO a limitation

As per my understanding, MongoDB Atlas does not support faceting on embedded documents, regardless of the type of facet.

Gotcha, Then hopefully someone from the mongo team can hop in here and confirm it is indeed an inaccuracy with the documentation and it should state that no faceting of any kind is supported within embeddedDocuments.

1 Like