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 安装配置
python库。 资源全名:django-haystack-1.2.4.tar.gz
django-haystack-elasticsearch 在上使用多个版本的Elasticsearch的一组后端。 免费软件:BSD许可证如何使用请确保您的elasticsearch库具有相同的主版本为您Elasticsearch服务器。 选择合适的后端作为Haystack上的...
mkvirtualenv django-haystack-solr-commands cd django-haystack-solr-commands python setup.py安装 您将需要wget,tar,rm 通过将at添加到您的服务器settings.py中,配置Haystack和此应用程序: HAYS
草垛 作者: 丹尼尔·林兹利 日期: 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
python库。 资源全名:django-jugemaj-2.0.1.tar.gz
资源来自pypi官网。 资源全名:django-userena-2.0.1.tar.gz
python库。 资源全名:django-static-sitemaps-2.0.1.tar.gz
资源分类:Python库 所属语言:Python 资源全名:django-statsd-2.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:django-exporter-2.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源来自pypi官网。 资源全名:django-schedule-commands-2020.12.29.tar.gz
资源来自pypi官网。 资源全名:django-schedule-commands-2020.12.24.tar.gz
django-rest-framework的官方文档,可以解压缩文件后,离线使用,十分的方便,网上关于rest的资料也是几乎没有,只有官方文档参考,可以多交流交流
Django-2.0.1压缩文件,解压后是一个文件夹,可以直接使用
django-cas-ng, Django ( 中央身份验证服务) 客户端 Django CAS django-cas-ng 是中央认证服务( CAS ) 客户端实现。 这里项目继承自 django-cas ( 自从 2013年04月 之后还没有更新过) 。 NG代表"下一代"。 我们的...
Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目Django-商城项目...
django-vue-admin发布教程.docx
django-rest中文文档django-rest中文文档django-rest中文文档django-rest中文文档django-rest中文文档django-rest中文文档django-rest中文文档django-rest中文文档
Django-1.8.2-中文文档,帮助Django开发人员加深理解。
django-admin-bootstrap-master.zip