-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Field Alias error when used in collapse query #32623
Description
Elasticsearch version : 7.x
Plugins installed: none
JVM version: java version "10" 2018-03-20
OS version: 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
Description of the problem including expected versus actual behavior:
Collapsing on a field alias returns an NPE, rather than the expected result of the collapse as applied to the field pointed to via the alias' path.
Steps to reproduce:
-
Bring up a local instance of elasticsearch, running latest
master. -
Index some docs using python script attached (you may need to
pip install elasticsearch,pip install fakerfor the script to work. Note thatpostal_codeis a field alias, pointing tozip_code, a long. populate.py.gz -
Run the following query
curl "http://localhost:9200/twitter/_search/" \
-H 'Content-Type: application/json' \
-d $'{
"query": {
"match_all": {}
},
"collapse" : {
"field" : "postal_code",
"inner_hits": [
{
"name": "by_postal_code",
"size": 3,
"collapse" : {"field" : "name"},
"sort": ["likes"]
}
]
}
}' | jq '.'
Observe the error.
- Contrast this response with the same query, but using the
zip_codefield instead
curl "http://localhost:9200/twitter/_search/" \
-H 'Content-Type: application/json' \
-d $'{
"query": {
"match_all": {}
},
"collapse" : {
"field" : "zip_code",
"inner_hits": [
{
"name": "by_postal_code",
"size": 3,
"collapse" : {"field" : "name"},
"sort": ["likes"]
}
]
}
}' | jq '.'
This query returns results as expected.
Provide logs (if relevant): The stacktrace for the error in step 2 is below.
[elasticsearch] [2018-08-03T13:28:42,185][DEBUG][o.e.a.s.TransportSearchAction] [node-0] Failed to execute [SearchRequest{searchType=QUERY_THEN_FETCH, indices=[twitter], indicesOptions=IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false], types=[], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=0, batchedReduceSize=512, preFilterShardSize=128, allowPartialSearchResults=true, source={"query":{"match_all":{"boost":1.0}},"collapse":{"field":"postal_code","inner_hits":{"name":"by_postal_code","ignore_unmapped":false,"from":0,"size":3,"version":false,"explain":false,"track_scores":false,"sort":[{"likes":{"order":"asc"}}],"collapse":{"field":"name"}}}}}] while moving to [expand] phase
[elasticsearch] java.lang.NullPointerException: null
[elasticsearch] at org.elasticsearch.action.search.ExpandSearchPhase.run(ExpandSearchPhase.java:79) ~[elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.AbstractSearchAsyncAction.executePhase(AbstractSearchAsyncAction.java:160) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:153) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.FetchSearchPhase.moveToNextPhase(FetchSearchPhase.java:205) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.FetchSearchPhase.lambda$innerRun$2(FetchSearchPhase.java:104) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.FetchSearchPhase.innerRun(FetchSearchPhase.java:110) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.FetchSearchPhase.access$000(FetchSearchPhase.java:44) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.action.search.FetchSearchPhase$1.doRun(FetchSearchPhase.java:86) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:723) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.0.0-alpha1-SNAPSHOT.jar:7.0.0-alpha1-SNAPSHOT]
[elasticsearch] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) [?:?]
[elasticsearch] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
[elasticsearch] at java.lang.Thread.run(Thread.java:844) [?:?]