Solr 查询不解析正斜杠 [英] Solr Query not parsing forward slash

查看:33
本文介绍了Solr 查询不解析正斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正斜杠/"是 solr 字段名称中的保留字符吗?

Is the forward slash "/" a reserved character in solr field names?

我在编写 solr 排序查询时遇到问题,该查询将解析包含正斜杠/"的字段

I'm having trouble writing a solr sort query which will parse for fields containing a forward slash "/"

对我的 solr 服务器进行 http 查询时:

When making an http query to my solr server:

q=*&sort=normal+desc

会起作用,但是

q=*&sort=with/slash+desc
q=*&sort=with%2Fslash+desc

两者都失败了,都说不能在多值字段上使用 FieldCache:with"

Both fail say "can not use FieldCache on multivalued field: with"

每个 solr 文档包含两个 int 字段normal"和with/slash".使用我的 solr 架构对字段进行索引

Each solr document contains two int fields "normal", and "with/slash". With my solr schema indexing the fields as so

...
<field name="normal" type="int"   indexed="true" stored="true" required="false" />
<field name="with/slash" type="int"   indexed="true" stored="true" required="false" />
...

有什么特殊的方法需要在 solr 中编码正斜杠吗?或者我可以使用其他任何分隔符吗?我已经在使用-"和."用于其他目的.

Is there any special way I need to encode forward slashes in solr? Or are there any other delimiter characters I can use? I'm already using '-' and "." for other purposes.

推荐答案

刚好遇到同样的问题,经过一些实验发现如果字段名有正斜杠,必须转义在 Solr 查询中使用反斜杠(但请注意,您不必在字段列表参数中执行此操作,因此输入了查找包含 my_value 的 /my/field/name 的搜索在q"字段中:

I just came across the same problem, and after some experimentation found that if you have a forward-slash in the field name, you must escape it with a backslash in the Solr query (but note that you do not have to do this in the field list parameter, so a search looking for /my/field/name containing my_value is entered in the "q" field as:

/my/field/name:my_value

我还没有尝试过排序字段,但试试这个并告诉我们:)

I haven't tried the sort field, but try this and let us know :)

这是在 Solr 4.0.0 alpha 上.

This is on Solr 4.0.0 alpha.

这篇关于Solr 查询不解析正斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆