Skip to content

Error using percolate search #1

@ZoRex15

Description

@ZoRex15

Environment

[project]
name = "manticore-mre"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "manticoresearch-asyncio>=1.0.0",
]

MRE

import asyncio
import manticoresearch


# CREATE TABLE IF NOT EXISTS pq (id BIGINT, duration BIGINT) TYPE='percolate';
# INSERT INTO pq (tags, query, filters) VALUES ('', '', 'duration > 200');

async def main():
    configuration = manticoresearch.Configuration(
        host = "http://127.0.0.1:9308"
    )
    async with manticoresearch.ApiClient(configuration) as api_client:
        search_api = manticoresearch.SearchApi(api_client)

        documents = [{"id": 1, "duration": 100}, {"id": 2, "duration": 200}, {"id": 3, "duration": 300}, {"id": 4, "duration": 400}]
        payload = {"query":{"percolate":{"documents": documents}}}
        response = await search_api.percolate("pq", payload)
        print(response)


if __name__ == "__main__":
    asyncio.run(main())

Error

File "F:\Progects\test_porgects\manticore_mre\.venv\Lib\site-packages\manticoresearch\models\search_response.py", line 97, in from_dict      
    "hits": SearchResponseHits.from_dict(obj["hits"]) if obj.get("hits") is not None else None,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\Progects\test_porgects\manticore_mre\.venv\Lib\site-packages\manticoresearch\models\search_response_hits.py", line 98, in from_dict 
    "hits": [HitsHits.from_dict(_item) for _item in obj["hits"]] if obj.get("hits") is not None else None
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\Progects\test_porgects\manticore_mre\.venv\Lib\site-packages\manticoresearch\models\hits_hits.py", line 90, in from_dict
    _obj = cls.model_validate({
           ^^^^^^^^^^^^^^^^^^^^
  File "F:\Progects\test_porgects\manticore_mre\.venv\Lib\site-packages\pydantic\main.py", line 716, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for HitsHits
_id
  Input should be a valid integer [type=int_type, input_value='2237250643393773569', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/int_type
_score
  Input should be a valid integer [type=int_type, input_value='1', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/int_type

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions