关于python:pymilvus-的-offset-参数不生效

45次阅读

共计 812 个字符,预计需要花费 3 分钟才能阅读完成。

谬误写法

def search_vector(vector: list[float], offset: int = 0, limit: int = 10) -> list[SearchResult]:
    from pymilvus.orm.search import SearchResult as MilvusSearchResult
    from loggers import logger

    logger.debug(f'offset: {offset}, limit: {limit}')
    rows: MilvusSearchResult = collection.search(data=[vector],
        param={
            "metric_type": 'L2',
            "nprobe": 32
        },
        anns_field='image_vector',
        output_fields=['id', 'hash_code'],
        limit=limit,
        offset=offset
    )

正确的写法

def search_vector(vector: list[float], offset: int = 0, limit: int = 10) -> list[SearchResult]:
    from pymilvus.orm.search import SearchResult as MilvusSearchResult
    from loggers import logger

    logger.debug(f'offset: {offset}, limit: {limit}')
    rows: MilvusSearchResult = collection.search(data=[vector],
        param={
            "metric_type": 'L2',
            "nprobe": 32,
            "offset": offset
        },
        anns_field='image_vector',
        output_fields=['id', 'hash_code'],
        limit=limit,
        # offset=offset
    )

正文完
 0