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

问题描述

正斜杠/"是 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 Query 不解析正斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:47
查看更多