0

我有约 113000 个文档的索引。我正在尝试检索所有这些,我不在乎分数。基本上是从索引中选择 *;

我正在使用 elasticutils 在 python 中执行此操作(还没有时间切换到 elasticsearch-dsl)

跑步

S().indexes('da_userstats').query().count()  

在大约 0.003 秒内完成。

跑步

S().indexes('da_userstats').query()[0:113595].execute().objects 

大约需要 15 秒。

根据我对文档的理解,两者都应该强制执行,所以我不明白为什么会有巨大的时间差异。

在映射中,我尝试将字段标记为不分析,但没有效果。我真的不明白为什么会有这么多数量级的差异。

@classmethod
def get_mapping(cls):
    return {
        'properties': {
            'id': {
                'type': 'integer',
                'index': 'not_analyzed',
                "include_in_all": False,
            },
            'email': {
                'type': 'string',
                'index': 'not_analyzed',
                "include_in_all": False
            },
            'username': {
                'type': 'string',
                'index': 'not_analyzed',
                "include_in_all": False
            },
            'date_joined': {
                'type': 'string',
                'index': 'not_analyzed',
                "include_in_all": False
            },
            'last_activity': {
                'type': 'string',
                'index': 'not_analyzed',
                "include_in_all": False
            },
            'last_activity_web': {
                'type': 'string',
                'index': 'not_analyzed',
                "include_in_all": False
            },
            'last_activity_ios': {
                'type': 'string',
                'index': 'not_analyzed',
                "include_in_all": False
            },
4

0 回答 0