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

Exception when searching using aggregation #41

Open
fpause opened this issue May 26, 2021 · 2 comments
Open

Exception when searching using aggregation #41

fpause opened this issue May 26, 2021 · 2 comments

Comments

@fpause
Copy link
Contributor

fpause commented May 26, 2021

First of all, thank you for creating an maintaining the project!

I started using flutter with elastic search yesterday and started using this package.

But when searching with an aggregation I unfortunately got an error in https://github.com/isoos/elastic_client/blob/master/lib/src/elastic_client_impl.dart in lines 130-134.

name = name;  
value = m['value'];  
values = m['values'] as Map;  
docCountErrorUpperBound = m['doc_count_error_upper_bound'] as int;  
sumOtherDocCount = m['sum_other_doc_count'] as int;  

My search query:

client.search(index: 'sensordata', type: '', aggregations: {
      'values': {
        'composite': {
          'sources': [
            {
              'value': {
                'terms': {'field': 'sensorname'}
              }
            }
          ]
        }
      }
    });

I looked up in the documentation https://pub.flutter-io.cn/documentation/elastic_client/latest/elastic_client/Aggregation-class.html and found that values for example should be of type Map? but is, as seen in the code block above of type Map.

After making the fields values, docCountErrorUpperBound and sumOtherDocCount nullable everything worked fine.

Can anybody confirm that problem?

@isoos
Copy link
Owner

isoos commented May 27, 2021

Yeah, that may be of a problem. Would you be able to create a PR with the fix? I'd be happy to review and merge it...

@fpause
Copy link
Contributor Author

fpause commented May 27, 2021

Yeah, that may be of a problem. Would you be able to create a PR with the fix? I'd be happy to review and merge it...

Yeah sure.

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