Tôi đã sử dụng Django Haystack một thời gian và thật tuyệt vời! Tôi có một trang web khá nặng với dữ liệu cần được cập nhật theo thời gian (15 đến 30 phút).Chỉ số cập nhật Django Haystack nhanh hơn
Khi sử dụng python manage.py update_index
phải mất rất nhiều thời gian để cập nhật dữ liệu. Có cách nào để tăng tốc độ này không? Hoặc có thể chỉ cập nhật dữ liệu đã thay đổi nếu có thể ..
Tôi hiện đang sử dụng Django Haystack 1.2.7 với Solr làm phụ trợ và Django 1.4.
Xin cảm ơn !!!
EDIT:
Có, tôi đã cố gắng đọc một phần của tài liệu nhưng những gì tôi thực sự cần là một cách để tăng tốc việc lập chỉ mục lên. Có thể chỉ cập nhật dữ liệu gần đây thay vì cập nhật tất cả. Tôi đã tìm thấy get_updated_field
nhưng không biết cách sử dụng nó. Trong tài liệu, nó chỉ được đề cập tại sao nó được sử dụng nhưng không có ví dụ thực tế nào được hiển thị.
EDIT 2:
start = DateTimeField(model_attr='start', null=True, faceted=True, --HERE?--)
EDIT 3:
Ok tôi đã thực hiện các giải pháp dưới đây nhưng khi tôi đã cố gắng rebuild_index (với 45000 dữ liệu) nó gần như bị rơi máy tính của tôi . Sau 10 phút chờ đợi một lỗi xuất hiện:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/rebuild_index.py", line 16, in handle
call_command('update_index', **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 150, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py", line 193, in handle
return super(Command, self).handle(*apps, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 304, in handle
app_output = self.handle_app(app, **options)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py", line 229, in handle_app
do_update(index, qs, start, end, total, self.verbosity)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py", line 109, in do_update
index.backend.update(index, current_qs)
File "/usr/local/lib/python2.7/dist-packages/haystack/backends/solr_backend.py", line 73, in update
self.conn.add(docs, commit=commit, boost=index.get_field_weights())
File "/usr/local/lib/python2.7/dist-packages/pysolr.py", line 686, in add
m = ET.tostring(message, encoding='utf-8')
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1127, in tostring
ElementTree(element).write(file, encoding, method=method)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 821, in write
serialize(write, self._root, encoding, qnames, namespaces)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 940, in _serialize_xml
_serialize_xml(write, e, encoding, qnames, None)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 940, in _serialize_xml
_serialize_xml(write, e, encoding, qnames, None)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 915, in _serialize_xml
write("<" + tag)
MemoryError
Bạn đã thử một số điều trong tài liệu Phương pháp hay nhất chưa? http://django-haystack.readthedocs.org/en/latest/best_practices.html#ref-best-practices – Spacedman
Tôi đã không sử dụng phần phụ trợ solr nên tôi không thể giúp bạn ở đó, xin lỗi. –