在Solr中运行http://localhost:8983/solr/amazon_products/select?q=*:*&fq=Category:"Toys \& Games "
此查询后,在转义特殊字符'&'时出现以下错误
{
"responseHeader": {
"zkConnected": true,
"status": 400,
"QTime": 0,
"params": {
"q": "*:*",
"Games \"": "",
"fq": "Category:\"Toys \\",
"rows": "70"
}
},
"error": {
"metadata": [
"error-class", "org.apache.solr.common.SolrException",
"root-error-class", "org.apache.solr.parser.TokenMgrError"
],
"msg": "org.apache.solr.search.SyntaxError: Cannot parse 'Category:\"Toys \\': Lexical error at line 1, column 17. Encountered: <EOF> after : \"\\\"Toys \\\\\"",
"code": 400
}}
“类别”字段包含如下值
"Category":["Toys & Games "," Learning & Education "," Science Kits & Toys"]
"Category":["Home & Kitchen "," Home Décor "," Window Treatments "," Window Stickers & Films ", " Window Films"],
类别字段的类型为字符串,多值=true
{
"name":"Category",
"type":"string",
"multiValued":true,
"stored":true},
如何正确搜索类别:“玩具和游戏“
注意:我尝试了http://localhost:8983/solr/amazon_products/select?q=*:*&fq=Category:Toys* AND *"Games "&rows=70
此查询,它运行良好,但如果我非常想搜索字符串'Toys & Games ',如何通过正确转义特殊字符'&'来实现此目的
1条答案
按热度按时间afdcj2ne1#
您需要对一些字符进行编码。例如以下命令:
将查询
fq=title_t:"Woody Herman & His Orchestra"
。请注意:
、"
、空格和&
字符是如何编码的。