Solr查询未解析正斜杠 [英] Solr Query not parsing forward slash
问题描述
solr字段名称中的斜杠"/"是保留字符吗?
我在编写Solr排序查询时遇到麻烦,该查询将解析包含正斜杠"/"的字段
对我的Solr服务器进行http查询时:
q=*&sort=normal+desc
可以,但是
q=*&sort=with/slash+desc
q=*&sort=with%2Fslash+desc
均失败的原因是不能在多值字段上使用FieldCache:"
每个solr文档都包含两个int字段"normal"和"with/slash".用我的Solr模式将字段编入索引
...
<field name="normal" type="int" indexed="true" stored="true" required="false" />
<field name="with/slash" type="int" indexed="true" stored="true" required="false" />
...
我有什么特殊的方法可以在solr中对正斜杠进行编码吗?还是我可以使用其他定界符?我已经在使用'-'和.".用于其他目的.
我遇到了同样的问题,经过一些实验后发现,如果字段名中有正斜杠,则必须将其转义在Solr查询中使用反斜杠(但请注意,您不必在字段列表参数中执行此操作,因此,在"q"字段中输入查找包含my_value的/my/field/name
的搜索为:>
\/my\/field\/name:my_value
我还没有尝试排序字段,但是尝试一下,让我们知道:)
这是在Solr 4.0.0 alpha上.
Is the forward slash "/" a reserved character in solr field names?
I'm having trouble writing a solr sort query which will parse for fields containing a forward slash "/"
When making an http query to my solr server:
q=*&sort=normal+desc
Will work but
q=*&sort=with/slash+desc
q=*&sort=with%2Fslash+desc
Both fail say "can not use FieldCache on multivalued field: with"
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" />
...
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.
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 :)
This is on Solr 4.0.0 alpha.
这篇关于Solr查询未解析正斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!