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

AttributeError: 'AggsProxy' object has no attribute '_index' #299

Closed
bepetersn opened this issue Jun 10, 2022 · 3 comments
Closed

AttributeError: 'AggsProxy' object has no attribute '_index' #299

bepetersn opened this issue Jun 10, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@bepetersn
Copy link

bepetersn commented Jun 10, 2022

This is probably not a bug on second glance, I must just be using the library incorrectly. Would love to receive that feedback. I am pretty new to this library as I am maintaining some legacy code.

This is (obviously) not on you, but for total context, this code worked before, in the sense that it didn't produce error at least, when I was using elasticsearch_dsl (version 6 -- with accompanying ESv6 product), but after upgrading, is causing a unittest failure with this error / code. I had to remove a reference to .aggs at line ~17 of the below code snippet on the rv of the first metric() call, where the comment with **** is located, before getting this error.

What is the bug?
Error with using aggregations:
AttributeError: 'AggsProxy' object has no attribute '_index'

How can one reproduce the bug?
Steps to reproduce the behavior:
I know this isn't enough, but it's a start...

from opensearch_dsl import Search, MultiSearch
from opensearch_dsl.query import Match, Terms, Term

rides = Search(using=client, index="rides")
ms = MultiSearch(using=client, index=index_name)
ms = ms.add(rides.filter(Term(normal_status=a)).extra(size=0))
ms = ms.add(rides.filter(Term(status=b)).extra(size=0))
ms = ms.add(rides.filter(Term(normal_status=c)).extra(size=0))
ms = ms.add(
    rides.filter(Terms(normal_status=[x, y, z])).extra(
        size=0
    )
)
ms = ms.add(
    rides.aggs
    .metric(                         
        "total_cost_incurred", "sum", field="cost_dollars"
    )                     # ****
    .metric(
        "cancellation_cost_incurred", "sum", field="cancellation_cost"
    )
)
responses = ms.execute()

What is the expected behavior?
I expect the execute() statement not to error out, at least.

What is your host/environment?

  • I am using this dockerhub image: opensearchproject/opensearch:1.2.4
  • OS: Amazon Linux 2
  • opensearch-dsl==1.0.0
  • opensearch-py==1.1.0

Do you have any additional context?
Traceback:

    responses = ms.execute()
  File "/Users/brian.peterson/project/venv/lib/python3.7/site-packages/opensearch_dsl/search.py", line 811, in execute
    index=self._index, body=self.to_dict(), **self._params
  File "/Users/brian.peterson/project/venv/lib/python3.7/site-packages/opensearch_dsl/search.py", line 794, in to_dict
    if s._index:
  File "/Users/brian.peterson/project/venv/lib/python3.7/site-packages/opensearch_dsl/utils.py", line 341, in __getattr__
    self.__class__.__name__, name
AttributeError: 'AggsProxy' object has no attribute '_index'

Anything else short of a full repro that would be of use? The index / mapping itself maybe?

@bepetersn bepetersn added the bug Something isn't working label Jun 10, 2022
@bepetersn bepetersn changed the title [BUG] [BUG] Error with using aggregations Jun 11, 2022
@bepetersn bepetersn changed the title [BUG] Error with using aggregations [BUG] Error with using aggregations: AttributeError: 'AggsProxy' object has no attribute '_index' Jun 11, 2022
@bepetersn bepetersn changed the title [BUG] Error with using aggregations: AttributeError: 'AggsProxy' object has no attribute '_index' [BUG] AttributeError: 'AggsProxy' object has no attribute '_index' Jun 11, 2022
@bepetersn bepetersn changed the title [BUG] AttributeError: 'AggsProxy' object has no attribute '_index' AttributeError: 'AggsProxy' object has no attribute '_index' Jun 11, 2022
@VachaShah VachaShah transferred this issue from opensearch-project/opensearch-dsl-py Feb 21, 2023
@github-actions github-actions bot added the untriaged Need triage label Feb 22, 2023
@VachaShah
Copy link
Collaborator

Transferring this issue here as opensearch-dsl-py is being merged into opensearch-py as part of #194

@wbeckler wbeckler removed the untriaged Need triage label Feb 22, 2023
@wbeckler
Copy link
Contributor

@bepetersn your issue hasn't gotten traction for a while. Is it still of interest to you? Would you have any more context to share that you've gleaned since then?

@saimedhi
Copy link
Collaborator

saimedhi commented Sep 8, 2023

please reopen the issue, if you think the bug still exists.

@saimedhi saimedhi closed this as completed Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants