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

Field Alias error when used in collapse query #32623

Closed
pcsanwald opened this issue Aug 3, 2018 · 2 comments
Closed

Field Alias error when used in collapse query #32623

pcsanwald opened this issue Aug 3, 2018 · 2 comments
Assignees
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v7.0.0-beta1

Comments

@pcsanwald
Copy link
Contributor

pcsanwald commented Aug 3, 2018

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:

  1. Bring up a local instance of elasticsearch, running latest master.

  2. Index some docs using python script attached (you may need to pip install elasticsearch, pip install faker for the script to work. Note that postal_code is a field alias, pointing to zip_code, a long. populate.py.gz

  3. 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.

  1. Contrast this response with the same query, but using the zip_code field 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) [?:?]
@pcsanwald
Copy link
Contributor Author

pcsanwald commented Aug 3, 2018

Discussed with @jtibshirani before opening to confirm that this seems like an actual bug; we're in agreement that it does seem like an actual issue. I did not test this on 6.x but suspect the same behavior will hold.

@pcsanwald pcsanwald added the :Analytics/Aggregations Aggregations label Aug 3, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@jtibshirani jtibshirani self-assigned this Aug 3, 2018
@jtibshirani jtibshirani added :Search Foundations/Mapping Index mappings, including merging and defining field types and removed :Analytics/Aggregations Aggregations labels Aug 6, 2018
@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v7.0.0-beta1
Projects
None yet
Development

No branches or pull requests

5 participants