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

NPE in query execution of boolean filter in 0.90.1 #3177

Closed
jredburn opened this Issue Jun 13, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@jredburn
Copy link

jredburn commented Jun 13, 2013

Attempting to upgrade to 0.90.1 (from 0.90.0) and seeing a new NPE for certain queries (specific generated boolean query with not section).

Details below -- happy to provide more information to help track down but haven't had any luck so far reducing this to simpler case.

The error is:

[2013-06-13 11:04:12,411][DEBUG][action.search.type       ] [Mop Man] [product-development-1][0], node[2njk8xyQQUSqmjVuG51JiA], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@4e299813]
org.elasticsearch.search.query.QueryPhaseExecutionException: [product-development-1][0]: query[filtered(ConstantScore(+QueryWrapperFilter(ToParentBlockJoinQuery (filtered(ConstantScore(+cache(properties.name.id:Product Category) +cache(properties.value.id:13351)))->cache(_type:__properties))) QueryWrapperFilter(ToParentBlockJoinQuery (filtered(ConstantScore(+cache(categories.name.id:Product Category) +cache(categories.value.id:13351)))->cache(_type:__categories))) +NotFilter(QueryWrapperFilter(ToParentBlockJoinQuery (filtered(ConstantScore(+cache(properties.name.id:ProductName) +cache(properties.value.id:drive converter)))->cache(_type:__properties))) QueryWrapperFilter(ToParentBlockJoinQuery (filtered(ConstantScore(+cache(categories.name.id:ProductName) +cache(categories.value.id:drive converter)))->cache(_type:__categories))))))->cache(org.elasticsearch.index.search.nested.NonNestedDocsFilter@953b6c6c)],from[0],size[10]: Query Failed [Failed to execute main query]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:138)
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:239)
    at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)
    at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:206)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:193)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:179)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
    at org.elasticsearch.common.lucene.docset.NotDocIdSet$IteratorBasedIterator.cost(NotDocIdSet.java:168)
    at org.elasticsearch.common.lucene.docset.AndDocIdSet$IteratorBasedIterator.<init>(AndDocIdSet.java:140)
    at org.elasticsearch.common.lucene.docset.AndDocIdSet.iterator(AndDocIdSet.java:82)
    at org.apache.lucene.search.ConstantScoreQuery$ConstantWeight.scorer(ConstantScoreQuery.java:135)
    at org.apache.lucene.search.FilteredQuery$RandomAccessFilterStrategy.filteredScorer(FilteredQuery.java:538)
    at org.apache.lucene.search.FilteredQuery$1.scorer(FilteredQuery.java:133)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:609)
    at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:161)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:482)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:438)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:134)
    ... 9 more

Query is:

{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "and": [
          {
            "or": [
              {
                "nested": {
                  "path": "properties",
                  "query": {
                    "filtered": {
                      "filter": {
                        "and": [
                          {
                            "term": {
                              "properties.name.id": "Product Category"
                            }
                          },
                          {
                            "term": {
                              "properties.value.id": "13351"
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              },
              {
                "nested": {
                  "path": "categories",
                  "query": {
                    "filtered": {
                      "filter": {
                        "and": [
                          {
                            "term": {
                              "categories.name.id": "Product Category"
                            }
                          },
                          {
                            "term": {
                              "categories.value.id": "13351"
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            ]
          },
          {
            "not": {
              "or": [
                {
                  "nested": {
                    "path": "properties",
                    "query": {
                      "filtered": {
                        "filter": {
                          "and": [
                            {
                              "term": {
                                "properties.name.id": "ProductName"
                              }
                            },
                            {
                              "term": {
                                "properties.value.id": "drive converter"
                              }
                            }
                          ]
                        }
                      }
                    }
                  }
                },
                {
                  "nested": {
                    "path": "categories",
                    "query": {
                      "filtered": {
                        "filter": {
                          "and": [
                            {
                              "term": {
                                "categories.name.id": "ProductName"
                              }
                            },
                            {
                              "term": {
                                "categories.value.id": "drive converter"
                              }
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    }
  },
  "fields": [
    "id"
  ]
}

@ghost ghost assigned s1monw Jun 13, 2013

@s1monw

This comment has been minimized.

Copy link
Contributor

s1monw commented Jun 13, 2013

thanks for reporting this.... I will get this fixed very soon, it's obvious but I need to add a test first.

@s1monw s1monw closed this in b995abf Jun 14, 2013

s1monw added a commit that referenced this issue Jun 14, 2013

Call DISI#cost() ahead of time to prevent NPE
NotDocIdSet resets the internal DocIdSetIterator to null causing NPE
if cost is called.

Closes #3177
@s1monw

This comment has been minimized.

Copy link
Contributor

s1monw commented Jun 14, 2013

the only workaround I can see is to use a Query for your NOT part instead of a filter by wrapping it into a

"fquery" : { "query" : { "bool" : { "not" : ... } } }

simon

@jredburn

This comment has been minimized.

Copy link
Author

jredburn commented Jun 14, 2013

Thanks much for the quick turnaround! We'll likely stick with 0.90.0 for now and look forward to the next release.

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Call DISI#cost() ahead of time to prevent NPE
NotDocIdSet resets the internal DocIdSetIterator to null causing NPE
if cost is called.

Closes elastic#3177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.