I have the following document in my collection

> {
	"_id": "101",
	"PublisherName": "Big book publishers",
	"Books": [
		{
			"_id": "6791913210",
			"Title": "Piano made simple",
			"Author": "John Bent"
		},
		{
			"_id": "6638200210",
			"Title": "Guitar made simple",
			"Author": "Kim Larry"
		}
	]
}

Ive defined the search index as follows

{
“mappings”: {
“dynamic”: false,
“fields”: {
“PublisherName”: {
“analyzer”: “lucene.standard”,
“type”: “string”
},
“Books”: {
“dynamic”: false,
“fields”: {
“Author”: {
“analyzer”: “lucene.standard”,
“type”: “string”
}
},
“type”: “embeddedDocuments”
}
}
}
}

I can search in the PublisherName or Author fields using seperate search definition

[Search PublisherName]

{
“index”: “book-search-Index”,
“compound”: {
“should”: [
{
“text”: {
“query”: “Big book publishers”,
“path”: [
“PublisherName”
]
}
}
]
}
}

or

[Search Books.Author]

> {
	"index": "book-search-Index",
	"embeddedDocument": {
		"path": "Books",
		"operator": {
			"compound": {
				"should": [
					{
						"text": {
							"path": ["Books.Author"],
							"query": "Guitar"
						}
					}
				]
			}
		}
	}
}

But im not able to define one search defination that is capable for searching both the PublisherName filed and Book.Author field. I tried the below but im getting error
Reason: at most one of [autocomplete, compound, embeddedDocument, equals, exists, geoShape, geoWithin, in, knnBeta, moreLikeThis, near, phrase, queryString, range, regex, search, span, term, text, wildcard] may be present

{
“index”: “book-search-Index”,
“compound”: {
“should”: [
{
“text”: {
“query”: “jonas”,
“path”: [
“BoardName”
],
“score”: {
“boost”: {
“value”: 1.0
}
}
}
}
]
},
“embeddedDocument”: {
“path”: “ClipCompliance”,
“operator”: {
“compound”: {
“should”: [
{
“text”: {
“path”: [“ClipCompliance.Contributors”,“ClipCompliance.Guidance”],
“query”: “required”
}
}
]
}
}
}
}

The clauses need to be nested within one of the compound arrays. compound.should , for example, could have both the text and embeddedDocument operators in it - whereas the code provided has embeddedDocument outside of compound.should array.

Also, embeddedDocuments mapping here is unnecessary, and possibly even problematic at scale. Nested structured mapped this way create additional “index objects” (Lucene documents). The only field you have on these embedded documents is “author” - which could be flattened and mapped through the document type instead. You can read more about embeddedDocuments here: Data Modeling and Schema Design for Atlas Search | MongoDB

The Books field is an Array of Books with two fileds “Title” and “Athor”. Therefore multiple Books are possible. How would you flatted such a structure?

Could you create a Search Playground to demonstrate your challenge here?

If you’re not querying both Title and Author together and need them to relate to the same book, there’s no need to use embeddedDocuments here. Queries to your collection in this structure returns Publishers, not individual books - that’s an important data modeling point here.