How to search multiple indexes with nested and non-nested fields ?
I have an audio index with the results like this :
{
"_index" : "audios",
"_type" : "_doc",
"_id" : "145",
"_score" : 9.143846,
"_source" : {
"id":145,
"audio_title" : "Title",
"main_artists" : [
{
"id" : 1,
"artist_name" : "Artist_name"
}
]
}
}
and an index artists with results like this :
{
"_index" : "artists",
"_type" : "_doc",
"_id" : "34",
"_version" : 2,
"_seq_no" : 130,
"_primary_term" : 1,
"found" : true,
"_source" : {
"id":34,
"artist_name" : "Artist_name"
}
}
My problem is when I do a search on the 2 indexes it gives me an error.
GET audios,artists/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{"match_phrase_prefix": {
"audio_title": "XXXX"
}},
{"nested": {
"path": "main_artists",
"query": {
"match_phrase_prefix": {
"main_artists.artist_name": "XXXX"
}
}
}}
]
}
}
]
}
}
}
The error:
"failures" : [
{
"shard" : 0,
"index" : "artists",
"node" : "sHio0-yeRaO8Z5qJXaczPw",
"reason" : {
"type" : "query_shard_exception",
"reason" : "failed to create query: [nested] failed to find nested object under path [main_artists]",
"index_uuid" : "etDWonKCSQietG3uK3ZnBA",
"index" : "artists",
"caused_by" : {
"type" : "illegal_state_exception",
"reason" : "[nested] failed to find nested object under path [main_artists]"
}
}
}
]