`

django-haystack2.0.1 commands 文档

 
阅读更多

Management Commands

Haystack comes with several management commands to make working with Haystack easier.

clear_index

The clear_index command wipes out your entire search index. Use with caution. In addition to the standard management command options, it accepts the following arguments:

``--noinput``:
    If provided, the interactive prompts are skipped and the index is
    uncerimoniously wiped out.
``--verbosity``:
    Accepted but ignored.
``--using``:
    If provided, determines which connection should be used. Default is
    ``default``.

By default, this is an INTERACTIVE command and assumes that you do NOT wish to delete the entire index.

Warning

Depending on the backend you’re using, this may simply delete the entire directory, so be sure yourHAYSTACK_CONNECTIONS[<alias>]['PATH'] setting is correctly pointed at just the index directory.

update_index

Note

If you use the --start/--end flags on this command, you’ll need to install dateutil to handle the datetime parsing.

The update_index command will freshen all of the content in your index. It iterates through all indexed models and updates the records in the index. In addition to the standard management command options, it accepts the following arguments:

``--age``:
    Number of hours back to consider objects new. Useful for nightly
    reindexes (``--age=24``). Requires ``SearchIndexes`` to implement
    the ``get_updated_field`` method. Default is ``None``.
``--start``:
    The start date for indexing within. Can be any dateutil-parsable string,
    recommended to be YYYY-MM-DDTHH:MM:SS. Requires ``SearchIndexes`` to
    implement the ``get_updated_field`` method. Default is ``None``.
``--end``:
    The end date for indexing within. Can be any dateutil-parsable string,
    recommended to be YYYY-MM-DDTHH:MM:SS. Requires ``SearchIndexes`` to
    implement the ``get_updated_field`` method. Default is ``None``.
``--batch-size``:
    Number of items to index at once. Default is 1000.
``--remove``:
    Remove objects from the index that are no longer present in the
    database.
``--workers``:
    Allows for the use multiple workers to parallelize indexing. Requires
    ``multiprocessing``.
``--verbosity``:
    If provided, dumps out more information about what's being done.

      * ``0`` = No output
      * ``1`` = Minimal output describing what models were indexed
        and how many records.
      * ``2`` = Full output, including everything from ``1`` plus output
        on each batch that is indexed, which is useful when debugging.
``--using``:
    If provided, determines which connection should be used. Default is
    ``default``.

Examples:

# Update everything.
./manage.py update_index --settings=settings.prod

# Update everything with lots of information about what's going on.
./manage.py update_index --settings=settings.prod --verbosity=2

# Update everything, cleaning up after deleted models.
./manage.py update_index --remove --settings=settings.prod

# Update everything changed in the last 2 hours.
./manage.py update_index --age=2 --settings=settings.prod

# Update everything between Dec. 1, 2011 & Dec 31, 2011
./manage.py update_index --start='2011-12-01T00:00:00' --end='2011-12-31T23:59:59' --settings=settings.prod

# Update just a couple apps.
./manage.py update_index blog auth comments --settings=settings.prod

# Update just a single model (in a complex app).
./manage.py update_index auth.User --settings=settings.prod

# Crazy Go-Nuts University
./manage.py update_index events.Event media news.Story --start='2011-01-01T00:00:00 --remove --using=hotbackup --workers=12 --verbosity=2 --settings=settings.prod

Note

This command ONLY updates records in the index. It does NOT handle deletions unless the --removeflag is provided. You might consider a queue consumer if the memory requirements for --remove don’t fit your needs. Alternatively, you can use the RealtimeSignalProcessor, which will automatically handle deletions.

rebuild_index

A shortcut for clear_index followed by update_index. It accepts any/all of the arguments of the following arguments:

``--age``:
    Number of hours back to consider objects new. Useful for nightly
    reindexes (``--age=24``). Requires ``SearchIndexes`` to implement
    the ``get_updated_field`` method.
``--batch-size``:
    Number of items to index at once. Default is 1000.
``--site``:
    The site object to use when reindexing (like `search_sites.mysite`).
``--noinput``:
    If provided, the interactive prompts are skipped and the index is
    uncerimoniously wiped out.
``--remove``:
    Remove objects from the index that are no longer present in the
    database.
``--verbosity``:
    If provided, dumps out more information about what's being done.

      * ``0`` = No output
      * ``1`` = Minimal output describing what models were indexed
        and how many records.
      * ``2`` = Full output, including everything from ``1`` plus output
        on each batch that is indexed, which is useful when debugging.
``--using``:
    If provided, determines which connection should be used. Default is
    ``default``.

For when you really, really want a completely rebuilt index.

build_solr_schema

Once all of your SearchIndex classes are in place, this command can be used to generate the XML schema Solr needs to handle the search data. It accepts the following arguments:

``--filename``:
    If provided, directs output to a file instead of stdout.
``--using``:
    If provided, determines which connection should be used. Default is
    ``default``.

Warning

This command does NOT update the schema.xml file for you. You either have to specify a filenameflag or have to copy-paste (or redirect) the output to the correct file. Haystack has no way of knowing where your Solr is setup (or if it’s even on the same machine), hence the manual step.

haystack_info

Provides some basic information about how Haystack is setup and what models it is handling. It accepts no arguments. Useful when debugging or when using Haystack-enabled third-party apps.

 

分享到:
评论

相关推荐

    django-haystack Elasticsearch

    django-haystack Elasticsearch 安装配置django-haystack Elasticsearch 安装配置django-haystack Elasticsearch 安装配置

    Python库 | django-haystack-1.2.4.tar.gz

    **Python库 django-haystack-1.2.4.tar.gz** `django-haystack`是Python社区中一个非常重要的库,特别适用于 Django 框架的全文搜索功能。这个资源,`django-haystack-1.2.4.tar.gz`,是一个归档文件,包含了版本...

    PyPI 官网下载 | django-schedule-commands-2020.12.24.tar.gz

    压缩包内的文件名称列表"django-schedule-commands-2020.12.24"暗示了该压缩包解压后会包含一个名为"django-schedule-commands-2020.12.24"的目录,这个目录中会有源代码、文档、测试和其他资源。通常,Python库的源...

    PyPI 官网下载 | django-schedule-commands-2020.12.29.tar.gz

    `django-schedule-commands-2020.12.29.tar.gz`这个压缩包包含了该库的源代码和其他相关文件,如文档、测试和配置文件。解压后,你可以查看`setup.py`文件,它是Python包的标准安装脚本,用于定义包的元数据和安装...

    PyPI 官网下载 | django-userena-2.0.1.tar.gz

    `django-userena-2.0.1.tar.gz`压缩包中包含了源码、文档、测试文件等,解压后可以查看其结构和具体实现,这对于开发者学习和定制`django-userena`非常有帮助。如果你打算在项目中使用`django-userena`,建议阅读...

    django-haystack-elasticsearch

    django-haystack-elasticsearch 在上使用多个版本的Elasticsearch的一组后端。 免费软件:BSD许可证如何使用请确保您的elasticsearch库具有相同的主版本为您Elasticsearch服务器。 选择合适的后端作为Haystack上的...

    django-haystack-solr-commands:manage.py solr

    mkvirtualenv django-haystack-solr-commands cd django-haystack-solr-commands python setup.py安装 您将需要wget,tar,rm 通过将at添加到您的服务器settings.py中,配置Haystack和此应用程序: HAYS

    Python库 | django-static-sitemaps-2.0.1.tar.gz

    **Python库 django-static-sitemaps-2.0.1** `django-static-sitemaps` 是一个针对Python的Django框架的扩展库,主要用于生成静态的XML站点地图。这个库可以帮助开发者方便地创建并维护适用于搜索引擎优化(SEO)的...

    Python库 | django-jugemaj-2.0.1.tar.gz

    "django-jugemaj-2.0.1.tar.gz"是一个Python库,专为Django框架设计,用于增强其功能或提供特定服务。 首先,让我们深入了解Django框架。Django提供了完整的解决方案,包括ORM(对象关系映射)系统,用于处理数据库...

    django-haystack:模块化搜索Django

    草垛 作者: 丹尼尔·林兹利 日期: 2013/07/28 Haystack为Django提供模块... v2.8.X: ://django-haystack.readthedocs.io/en/v2.8.1/ v2.7.X: ://django-haystack.readthedocs.io/en/v2.7.0/ v2.6.X: ://dj

    基于django-haystack的中文分词与全文搜索集成设计源码

    该源码是基于Django框架与django-haystack的中文分词与全文搜索集成设计,包含69个文件,包括39个Python源代码文件、26个Python编译文件、2个XML配置文件、1个Markdown文件和1个HTML文件。项目旨在实现中文内容的...

    Python库 | django-statsd-2.0.1.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:django-statsd-2.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python-djangohaystackDjango模块化搜索

    在 `django-haystack-django-haystack-1f01077` 这个压缩包文件中,包含了特定版本的 django-haystack 源代码,开发者可以通过阅读源码了解其内部实现机制,或者在遇到问题时进行调试和定制。在实际项目中,根据具体...

    高效易用Django流程引擎源码 - django-lb-workflow

    项目概述:django-lb-workflow 是一个基于Python的高效易用Django流程引擎源码,旨在轻松集成至现有系统。该项目主要由68个Python文件、30个HTML文件以及其他相关文件构成,共计136个文件。其中还包括了HTML模板、...

    Python库 | django-exporter-2.0.1.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:django-exporter-2.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | django-aliyun-oss2-storage-0.1.1.tar.gz

    《Python库django-aliyun-oss2-storage:阿里云OSS2存储服务的Django集成》 在Python的开发世界中,Django是一款强大的Web框架,而阿里云OSS(Object Storage Service)则是一个广泛使用的云存储服务。当这两者结合...

    Django-商城项目

    Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目...

    Django-1.2.5.tar.gz

    "Django-1.2.5.tar.gz" 是一个包含Django 1.2.5版本源代码的压缩文件,使用的是常见的归档格式tar与gzip的组合。在本文中,我们将深入探讨Django框架及其1.2.5版本中的关键特性、安装方法、核心概念以及在实际项目中...

    PyPI 官网下载 | django-tables2-column-shifter-0.3.0.tar.gz

    《PyPI官网下载:django-tables2-column-shifter-0.3.0.tar.gz》 在Python的世界里,PyPI(Python Package Index)是开发者们分享和获取Python软件包的重要平台。今天我们要讨论的是其中的一个特定包——`django-...

    django-sslserver, Django 启用的SSL开发服务器.zip

    django-sslserver, Django 启用的SSL开发服务器 Django SSL服务器 Django SSL服务器是 Django 框架的一个已经启用SSL的开发服务器。请注意,这里不应用于生产设置。 这个应用适用于特殊的用例。 但是,大多数人应该...

Global site tag (gtag.js) - Google Analytics