Created
January 29, 2014 04:26
-
-
Save seallison/8681846 to your computer and use it in GitHub Desktop.
NPE when doing hasParentFilter with a nestedFilter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2014-01-28 23:08:50,080][DEBUG][action.search.type ] [Double Helix] [3] Failed to execute fetch phase | |
java.lang.NullPointerException | |
at org.elasticsearch.index.search.child.ParentConstantScoreQuery$ChildrenWeight$ChildrenDocIdIterator.match(ParentConstantScoreQuery.java:176) | |
at org.apache.lucene.search.FilteredDocIdSetIterator.advance(FilteredDocIdSetIterator.java:71) | |
at org.elasticsearch.index.search.child.ConstantScorer.advance(ConstantScorer.java:70) | |
at org.apache.lucene.search.ConstantScoreQuery$ConstantScorer.advance(ConstantScoreQuery.java:217) | |
at org.apache.lucene.search.ConstantScoreQuery$ConstantWeight.explain(ConstantScoreQuery.java:166) | |
at org.apache.lucene.search.FilteredQuery$1.explain(FilteredQuery.java:102) | |
at org.apache.lucene.search.IndexSearcher.explain(IndexSearcher.java:672) | |
at org.apache.lucene.search.IndexSearcher.explain(IndexSearcher.java:652) | |
at org.elasticsearch.search.internal.ContextIndexSearcher.explain(ContextIndexSearcher.java:192) | |
at org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase.hitExecute(ExplainFetchSubPhase.java:72) | |
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:197) | |
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:434) | |
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:406) | |
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeFetch(TransportSearchDfsQueryThenFetchAction.java:249) | |
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$5.run(TransportSearchDfsQueryThenFetchAction.java:233) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) | |
at java.lang.Thread.run(Thread.java:744) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"template_products": { | |
"template": "products*", | |
"mappings": { | |
"products": { | |
"_all": { | |
"enabled": false | |
}, | |
"_source": { | |
"compress": true | |
}, | |
"properties": { | |
"_id": { | |
"index": "not_analyzed", | |
"type": "string" | |
}, | |
"items": { | |
"type": "nested", | |
"include_in_parent": true, | |
"properties": { | |
"itemId": { | |
"index": "not_analyzed", | |
"type": "string" | |
}, | |
"companyId": { | |
"type": "long" | |
} | |
} | |
} | |
} | |
}, | |
"items": { | |
"_all": { | |
"enabled": false | |
}, | |
"_parent": { | |
"type": "products" | |
}, | |
"_routing": { | |
"required": true, | |
"path": "productId" | |
}, | |
"_source": { | |
"compress": true | |
}, | |
"properties": { | |
"_id": { | |
"index": "not_analyzed", | |
"type": "string" | |
}, | |
"description": { | |
"type": "string" | |
}, | |
"productId": { | |
"index": "not_analyzed", | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BoolFilterBuilder boolFilter = FilterBuilders.boolFilter(); | |
boolFilter.must(FilterBuilders.termFilter("items.itemId", itemId)); | |
boolFilter.must(FilterBuilders.termFilter("items.companyId", session.getCompanyId())); | |
NestedFilterBuilder crossCompanyFilter = FilterBuilders.nestedFilter("items", boolFilter); | |
FilteredQueryBuilder fqb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FilterBuilders.hasParentFilter("products", crossCompanyFilter)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment