Nested: SearchParseException when query to non-existing type


(Xudong You) #1

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?


(Xudong You) #2

Any suggestion?
Somehow, I think it is ES's bug, since it should simply return empty result if the type does not exist. Actually, ES has different behavior for non-existing type query. If I remove the function score part from the query, the request won't throw exception for non-existing type.


(system) #3