I create an index with multiple types all of which has a nested field defined as follows:
"AssocQueries": {
"type": "nested",
"properties": {
"Term": {
"type": "string",
"fields": {
"exact": {
"type": "string", "analyzer": "lowercase_keyword"
}
}
},
"Count": {
"type": "long"
}
}
},
And in queries to all type, there is a nested query with function score as follows:
{
"nested": {
"path": "AssocQueries",
"query": {
"function_score": {
"query": {
"match": {
"exact": "blah blah..."
}
},
functions: [{
}],
}
}
}
}
The problem is, if I send the query to a non-existing type, example, localhost:9200/myindex/badtype/_search, I will get exception:
[nested] failed to find nested object under path [AssocQueries]]
I know I can check if the type is valid before run the query, but is there any other simple ways to avoid such exception even send query to an invalid type?