Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indices filter parsed for indices to which it should not apply #2416

Closed
clintongormley opened this issue Nov 16, 2012 · 1 comment
Closed

Comments

@clintongormley
Copy link

A used in the forum is trying to apply a nested filter to just one index, while querying more than one index, some of which don't have the nested mapping.

The query is complaining about a missing nested mapping, but on the indices to which the query should not apply.

Create two indices: test_1 with a nested mapping, and test_2 without a nested mapping:

curl -XPUT 'http://127.0.0.1:9200/test_1/?pretty=1'  -d '
{
   "mappings" : {
      "foo" : {
         "properties" : {
            "authors" : {
               "type" : "nested",
               "properties" : {
                  "name" : {
                     "type" : "string"
                  }
               }
            },
            "title" : {
               "type" : "string"
            }
         }
      }
   }
}
'

curl -XPUT 'http://127.0.0.1:9200/test_2/?pretty=1'  -d '
{
   "mappings" : {
      "bar" : {
         "properties" : {
            "title" : {
               "type" : "string"
            }
         }
      }
   }
}
'

Index some data:

curl -XPOST 'http://127.0.0.1:9200/test_1/foo?pretty=1'  -d '
{
   "author" : {
      "name" : "john smith"
   },
   "title" : "test 1 doc"
}
'

curl -XPOST 'http://127.0.0.1:9200/test_2/bar?pretty=1'  -d '
{
   "title" : "test 2 doc"
}
'

Query test_1 and test_2 but limit the nested filter to just test_1:

curl -XGET 'http://127.0.0.1:9200/test_1%2Ctest_2/_search?pretty=1'  -d '
{
   "query" : {
      "filtered" : {
         "filter" : {
            "indices" : {
               "no_match_filter" : "none",
               "filter" : {
                  "nested" : {
                     "filter" : {
                        "term" : {
                           "author.name" : "john"
                        }
                     },
                     "path" : "author"
                  }
               },
               "indices" : [
                  "test_1"
               ]
            }
         },
         "query" : {
            "match" : {
               "title" : "test"
            }
         }
      }
   }
}
'

Throws this error:

SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[Yit05d94RgiUwMg9vzMOgw][test_1][1]: SearchParseException[[test_1][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{
   "query" : {
      "filtered" : {
         "filter" : {
            "indices" : {
               "no_match_filter" : "none",
               "filter" : {
                  "nested" : {
                     "filter" : {
                        "term" : {
                           "author.name" : "john"
                        }
                     },
                     "path" : "author"
                  }
               },
               "indices" : [
                  "test_1"
               ]
            }
         },
         "query" : {
            "match" : {
               "title" : "test"
            }
         }
      }
   }
}
@andrewclegg
Copy link

I've seen this behaviour too. I have a horrible feeling that it's causing a whole pile of extra work on our cluster. If someone's running a search that only covers two weeks of data, we really don't want to start dozens of extra threads for the rest of the year, even if ultimately they return no data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants