0

我正在使用 scorched 将我的 Django 代码与我的 Solr 实例连接:

response = si.query(DismaxString(querydict.get('q')).execute()

在我正在搜索的数据中,我有冒号(例如 Col: Mackay's Reel),我不希望 Solr 将该冒号解释为“字段”查询:

   "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"undefined field Col"

如何转义用户在查询中输入的所有冒号?

即使直接在 Solr 查询界面上,我也会收到错误消息。

4

1 回答 1

0

现在我的解决方法是在发送表单之前通过 JavaScript 为每个冒号添加一个反斜杠,以便冒号作为“:”发送。

于 2021-01-02T14:35:04.213 回答