Reputation: 888
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",
"text": {
"query": "Big book publishers",
"path": ["PublisherName"]
}
}
or
[Search Books.Author]
{
"index": "book-search-Index",
"embeddedDocument": {
"path": "Books",
"operator": {
"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",
"text": {
"query": "Big book publishers",
"path": ["PublisherName"]
}
"embeddedDocument": {
"path": "Books",
"operator": {
"text": {
"path": ["Books.Author"],
"query": "Guitar"
}
}
}
}
Upvotes: 0
Views: 61
Reputation: 888
The solution to this issues is
{
"index": "book-search-Index",
"compound": {
"should": [
{
"embeddedDocument": {
"path": "Books",
"operator": {
"compound": {
"should": [
{
"text": {
"path": ["Books.Author"],
"query": "Guitar"
}
}
]
}
}
}
},
{
"text": {
"query": "Big book publishers",
"path": ["PublisherName"]
}
}
]
}
}
Upvotes: 0