pyravendb查询参数解析错误

pyravendb query parameters parsing error

我注意到 ravendb 的 python 客户端有一个奇怪的解析问题。 当我使用这个查询时

query_result = list(session.query().where_equals("url",url).select("Id","htmlCode","url"))

知道 url = "http://www.mywebsite.net/"

错误堆栈的相关部分如下:

  File "/usr/local/lib/python3.5/dist-packages/pyravendb/store/session_query.py", line 71, in __iter__
    return self._execute_query().__iter__()
  File "/usr/local/lib/python3.5/dist-packages/pyravendb/store/session_query.py", line 307, in _execute_query
    includes=self.includes)
  File "/usr/local/lib/python3.5/dist-packages/pyravendb/d_commands/database_commands.py", line 286, in query
    raise exceptions.ErrorResponseException(response["Error"][:100])
pyravendb.custom_exceptions.exceptions.ErrorResponseException: Lucene.Net.QueryParsers.ParseException: Could not parse: 'url:http://www.mywebsite.net/' ---> 

但是,如果我简单地向查询中的 url 参数添加一个简单的 ' ',它会在没有任何解析错误的情况下工作(但是发送 returns 结果,因为语法不是相同)。

我想为 github 上的 pyravendb 做出贡献,但我不确定它在哪里解析参数,它可能正在为此调用 lucene

知道为什么简单的 space 会妨碍正确的解析吗?

你发送给lucene的查询是这样的url:http://www.mywebsite.net/

lucene 键将是 url,值应该是 http://www.mywebsite.net/ 因为你在 http://www.mywebsite.net/ 中有 :,lucene 解析器得到 "confused" 并引发解析错误。(拆分键,值特殊字符是 :

要解决您的问题,您需要转义 url 参数中的 :,然后将其提供给查询,因此您的 url 参数应如下所示: http\://www.mywebsite.net/

关于为什么简单 space 可以阻止正确解析的问题是因为 lucene 中的 space 指示要查找的另一个参数。 (您可以在使用 where_in 方法时看到我们构建的查询)

下一个版本的pyravendb(当前版本是1.3.1.1)会修复这个问题