elasticsearch 如何在elasticsearch dsl(5.4.0)中使用搜索API中的索引,elasticsearch,elasticsearch-dsl,elasticsearch,elasticsearch Dsl" /> elasticsearch 如何在elasticsearch dsl(5.4.0)中使用搜索API中的索引,elasticsearch,elasticsearch-dsl,elasticsearch,elasticsearch Dsl" />

elasticsearch 如何在elasticsearch dsl(5.4.0)中使用搜索API中的索引

elasticsearch 如何在elasticsearch dsl(5.4.0)中使用搜索API中的索引,elasticsearch,elasticsearch-dsl,elasticsearch,elasticsearch Dsl,我正在使用elasticsearch dsl(5.4.0)和elasticsearch(5.5.3)。我在模型层文件中使用名为Meta class的内部类定义了EsTask类,如下所示: /task_models.py class EsTask(DocType): id = Keyword() catagory_id = Integer() name = Text(analyzer='ik_max_word', search_analyzer='ik_smart')

我正在使用elasticsearch dsl(5.4.0)和elasticsearch(5.5.3)。我在模型层文件中使用名为Meta class的内部类定义了EsTask类,如下所示:

/task_models.py

class EsTask(DocType):
    id = Keyword()
    catagory_id = Integer()
    name = Text(analyzer='ik_max_word', search_analyzer='ik_smart')
    priority_level = Integer()
    related_id = Keyword()
    parent_id = Keyword()
    creator_id = Keyword()
    created_at = Date()
    deleted_at = Date()

    class Meta:
        index = 'task_es'
        doc_type = 'main'
我在控制器层文件中调用搜索API:

/task.py

s = EsTask.search().filter('bool', must_not=elasticsearch_dsl.Q('exists', field='deleted_at'))

如果我想确保搜索API使用我在上面的Meta类中定义的索引,我可以像预期的那样使用调用search()的关键字参数吗?或者这是必须的,我可以不带任何参数地离开搜索API?

您可以不带任何参数地离开它,因为它会自动完成


希望这有帮助

我真的很感谢你的帮助,特别是来自组织成员的帮助。我是一名Python开发人员,专攻烧瓶领域。中国的开源环境正在发展,但仍处于初级阶段。我真的希望能为开源社区做出一些贡献。你的回答真的激发了我的热情。抬我上去!