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

Empty array becomes null in source #554

Closed
Swarlston opened this issue Jul 12, 2017 · 2 comments
Closed

Empty array becomes null in source #554

Swarlston opened this issue Jul 12, 2017 · 2 comments
Assignees

Comments

@Swarlston
Copy link

Which version of Elastic are you using?

[ ] elastic.v2 (for Elasticsearch 1.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[x ] elastic.v5 (for Elasticsearch 5.x)

Please describe the expected behavior

When using a terms query and passing an empty array, the query body should also
contain an empty array []

included := make([]string, 0)
filter.Filter(elasticsearch.NewTermsQuery("tags", included...))

should result in

 "terms": {
     "tags": []
 }

Please describe the actual behavior

but instead i get

 "terms": {
     "tags": null
 }

This leads to an exception:

"type": "parsing_exception",
    "reason": "[terms] unknown token [VALUE_NULL] after [tags]",
    "line": 15,
    "col": 29

Notes

I think this is because the array of values in
search_queries_terms.go is not initialized.

I'm not sure whether this is the correct form to report this, nor do
i know whether the problem isn't with ES itself. ( The documentation indicates that
null and [] are equivalent at some point )

@olivere
Copy link
Owner

olivere commented Jul 17, 2017

Thanks for supporting Elastic. I will investigate and post my findings here.

@olivere olivere self-assigned this Jul 17, 2017
@olivere
Copy link
Owner

olivere commented Jul 18, 2017

5.0.42 will properly initialize the values. I added a test case so that it will fail in the future if I'm missing it again.

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

No branches or pull requests

2 participants