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

redisearch ft().profile encounter error #3302

Open
xRay2016 opened this issue Jul 2, 2024 · 1 comment
Open

redisearch ft().profile encounter error #3302

xRay2016 opened this issue Jul 2, 2024 · 1 comment

Comments

@xRay2016
Copy link

xRay2016 commented Jul 2, 2024

Version: 5.0.4

Platform: python 3.7.16 on mac

Description: When I use ft.profile() command, it seems that the result is not parsed correctly. The error log is as follow:

client = Redis<ConnectionPool<Connection<host=redis-sy018bfbwp5w97ckz.redis.volces.com,port=6379,db=0>>>

    @pytest.mark.redismod
    @pytest.mark.onlynoncluster
    def test_profile_limited(client):
        client.ft().create_index((TextField("t"),))
        client.ft().client.hset("1", "t", "hello")
        client.ft().client.hset("2", "t", "hell")
        client.ft().client.hset("3", "t", "help")
        client.ft().client.hset("4", "t", "helowa")
    
        q = Query("%hell% hel*")
        if is_resp2_connection(client):
>           res, det = client.ft().profile(q, limited=True)

tests/test_search.py:1952: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/Caskroom/miniconda/base/envs/test/lib/python3.7/site-packages/redis/commands/search/commands.py:616: in profile
    PROFILE_CMD, res, query=query, duration=(time.time() - st) * 1000.0
/usr/local/Caskroom/miniconda/base/envs/test/lib/python3.7/site-packages/redis/commands/search/commands.py:70: in _parse_results
    return self._RESP2_MODULE_CALLBACKS[cmd](res, **kwargs)
/usr/local/Caskroom/miniconda/base/envs/test/lib/python3.7/site-packages/redis/commands/search/commands.py:98: in _parse_profile
    with_scores=query._with_scores,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'Result' object has no attribute 'total'") raised in repr()] Result object at 0x7fdd7050aa50>
res = 3, hascontent = True, duration = 38.774967193603516, has_payload = False
with_scores = False

    def __init__(
        self, res, hascontent, duration=0, has_payload=False, with_scores=False
    ):
        """
        - **snippets**: An optional dictionary of the form
        {field: snippet_size} for snippet formatting
        """
    
>       self.total = res[0]
E       TypeError: 'int' object is not subscriptable

/usr/local/Caskroom/miniconda/base/envs/test/lib/python3.7/site-packages/redis/commands/search/result.py:19: TypeError
@xRay2016
Copy link
Author

xRay2016 commented Jul 2, 2024

I check the response of command, it matches the format in https://redis.io/docs/latest/commands/ft.profile/

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

1 participant