【发布时间】:2014-08-17 04:46:08
【问题描述】:
版本:
CentOS - 6.4 (Final)
Haystack - 2.1.0
ElasticSearch - 1.2.1
Java - 1.7.0_55
Django-cms - 2.3.1
pyelasticsearch - 0.6
我在 CentOS 机器的 Django 项目中使用 ElasticSearch 时遇到问题。我习惯在 Ubuntu 机器上配置 Elasticsearch/Haystack,从来没有遇到过这样的问题。
我收到此错误Parse Failure [No parser for element [????????y????]],但我有一个空索引。我试图确切地知道错误来自哪里,所以我尝试了:
- 删除索引并重试(得到同样的错误)
- 尝试使用空索引(得到相同的错误)
- 安装/重新安装 -> 清除并重新安装
- 我尝试过使用较旧和较新的 ES 版本(0.90、1.2、1.1..)
- 检查 JAVA 版本
- 查找版本不兼容性 -
起初我以为错误是由索引的内容引起的,我试图索引的数据,但删除/清除索引后,我仍然得到同样的错误。
我正在尝试在模板中显示一个空查询集(因为我不知道还有什么试图找出问题所在)
其他信息
当我用python manage.py shell 打开 Django shell 并制作时
from haystack.query import SearchQuerySet
SearchQuerySet()
SearchQuerySet().all()
SearchQuerySet().filter(content='any_text')
这种查询运行没有问题,如果没有找到任何东西,则返回空查询集,如果找到,则返回查询集。尝试在我的视图中使用该命令并将结果返回到模板时出现错误和问题。在shell中一切正常,如果索引为空返回空查询集,如果索引有值返回它必须返回的值
search_indexes.py
import datetime
from haystack import indexes
from django.contrib.auth.models import User
from cms.models import CMSPlugin, Page
class CMSPluginIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
plugin_type = indexes.CharField(model_attr='plugin_type')
language = indexes.CharField(model_attr='language')
def get_model(self):
return CMSPlugin
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()
cms_plugin_text.txt
{{object.language}} # I added just this field to make sure is not the content of this
resume of views.py
def search_query(request):
sqs = SearchQuerySet().all()
return HttpResponse(sqs)
Django 错误
Invalid JSON returned from ES: <Response [404]>
Exception Value: Invalid JSON returned from ES: <Response [404]>
控制台中的完整 ElasticSearch 错误跟踪
[DEBUG][action.search.type] [Futurist] [haystack][2], node[inisR695RtGZ_WnEnkRr1w], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@28cfe3d9] lastShard [true]
org.elasticsearch.search.SearchParseException: [haystack][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"\ud900\udc71\ud840\udc65y\u0000\ud840\udc61":
{"\uda00\udc66\ud8c0\udc6c\ud840\udc65\ud8c0\udc65\ud8c0\udc00a\uda00\udc42\udac0\udc65":
{"\uda00\udc66\ud8c0\udc6c\ud840\udc65\u0000\ud880\udc25\udbc0\udc20":
{"\ud800\udc66\ud900\udc75\uda00\udc72\u0000\ud880\udc25\ud8c0\udc20":
{"\ud900\udc71\ud840\udc65y\u0000\ud840\udc61":
{"\ud900\udc71\ud840\udc65\udb80\udc79\ud8c0\udc73\uda00\udc72\ud980\udc6e\u0000\u0000\uda00
\udc64\ud8c0\udc73\udb40\udc61\ud900\udc63": {"\ud900\udc71\ud840\udc65y\u0000\ud840\udc61":
"\uda40\udc64\udb40\udc61\udb80\udc67\ud880\udc5f\uda40\udc74\ud880\udc28\ud880\udc6d\ud880\
udc2e\ud880\udc6d\udac0\udc70\ud980\udc75\udb40\udc69\udb80\udc20\udbc0\udc52\ud840\udc70\ud
b40\udc6f\uda80\udc6f\udac0\udc61\ud880\udc5f\ud800\udc68\ud900\udc72\udb40\udc64\udb80\udc6
3\udb40\udc75\ud840\udc74\uda00\udc79\ud880\udc00\u0000\u0002\u0000\uda34\ude80\u7f8eD\u0000
\udbbf\udfff\udbbf\udfff\u0000\ud917\udc22\udbcc\udc38\ud899\udc75\ud917\udc36\udbcc\udc39\u
d899\udc75\ud917\udc35\udbcc\udc61\ud899\udc75\ud917\udc32\udbcc\udc30\ud9d9\udc75\ud917\udc
30\ud90c\ude63\ud9d9\udc75"}},
"\ud880\udc5f\ud880\udc61\ud900\udc68\u0000\udb80\udc70\udb40\udc69": true}},
"\ud900\udc71\ud840\udc65y\u0000\ud840\udc61":
{"\ud900\udc71\ud840\udc65\udb80\udc79\ud8c0\udc73\uda00\udc72\ud980\udc6e\u0000\u0000\uda00
\udc64\ud8c0\udc73\udb40\udc61\ud900\udc63": {"\ud900\udc71\ud840\udc65y\u0000\ud840\udc61":
"\ud900\udc28)\ud89d\udc30",
"\ud900\udc64\ud800\udc66\udac0\udc75\udb80\udc74\udbc0\udc6f\ud840\udc65\ud8c0\udc61\ud840\
udc6f\u0000\ud99b\udf6c\udb40\udc61\udac0\udc61\uda40\udc79\udb80\udc65\uda00\udc77\ud8c0\ud
c6c": "\udb40\udc41D\ud8c0\udc67",
"\ud900\udc64\ud800\udc66\udac0\udc75\udb80\udc74\uda00\udc66\udac0\udc65d\u0000\u0001\u0000
\uda18\ude40\u7f8e\u0001": "\ud900\udc74\ud8c0\udc78\udbc0\udc00\udb00\udc65",
"\ud900\udc61\udb80\udc74\ud980\udc5f\udb40\udc65\ud840\udc65\ud8c0\udc61\udb80\udc65\ud9c0\
udc70\ud800\udc72\ud900\udc73\ud800\udc5f\ud900\udc75\uda00\udc72\ud880\udc65\ud8c0\udc00\u7
36c\u0000\u0000\udba4\udc30\u7f8e\udbbf\udffe\udbbf\udfff\u0001\u0000\u0001\u0000\uda38\ude8
0\u7f8e": true,
"\udb40\udc61\udac0\udc61\uda40\udc79\udb80\udc65\uda00\udc77\ud8c0\udc6c\ud800\udc63\ud8c0\
udc72\ud880\udc00\u7f8e\b\u0000\uda34\ude80\u7f8e\u0003\u0000": true}}}},
"\ud840\udc66\udb00\udc6f\ud840\udc00\u7f8e": 0, "\uda00\udc73\ud900\udc7a\u0000\u0000":
20}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:634)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:507)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:480)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:252)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:202)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:203)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:186)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.elasticsearch.search.SearchParseException: [haystack][3]: from[-1],size[-1]: Parse Failure [No parser for element [????????y????]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:620)
... 11 more
如果您需要任何其他信息来弄清楚这里发生了什么,请不要犹豫,我会尽快发布。
我在想问题可能来自pyelasticsearch。有人遇到过类似的问题吗?
编辑
我尝试了另一件事,我在 Ubuntu 服务器中安装了 ElasticSearch,并从 CentOS 向 Ubuntu 进行查询。我正在从 django-cms 索引 CMSPlugin 模型,并且插件的正文/文本似乎包含一些特殊字符,Java 或 Elasticsearch 无法尝试解析。这是导致 ElasticSearch/Java 崩溃的第一个字符串\ud900\udc71\ud840\udc65y\u0000\ud900\udc74。
我在 python 控制台中试过这个
c=u'\ud900\udc71\ud840\udc65y\u0000\ud900\udc74'
print c
输出:????????y????
编辑 2
我想知道 CentOS 上的 Java 是否有问题,我尝试将 Java 版本降级到 1.6,但没有成功
编辑 3
现在我直接使用 ElasticSearch,使用 urllib2 对 elasticsearch 进行查询,避免使用 Haystack。 ElasticSearch 完美地回答了查询(我必须管理 JSON)。我认为问题是 Haystack 是如何生成或解析查询的,因为当我尝试使用 SearchQuerySet() 并使用 shell 或在视图中制作类似 SearchQuerySet().filter(content='whatever') 的东西时,ElasticSearch 会因上述错误而崩溃,但在执行 @ 时效果很好987654337@
编辑 4
最后我直接使用最后一个 ElasticSearch 而不使用 Haystack。似乎问题在于 Haystack/pyelasticsearch 如何格式化查询以发送到 ES,它无法解析编码并且在每个请求中都失败。
我没有找到任何解决方案,只是避免与 Haystack 合作,如果有人能指出解决方案会很棒,我还给 Haystack 人发了一封电子邮件,看看他们是否已经注意到这个问题。
编辑 5
如果有人在 CentOS 上配置了 Haystack,我将不胜感激任何有关配置和软件版本的指南。我在 CentOS 上运行 ElasticSearch,但我直接通过 ElasticSearch 管理查询,完全忽略了 Haystack
【问题讨论】:
标签: python django elasticsearch centos django-haystack