Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
909 views
in Technique[技术] by (71.8m points)

lucene - Solr Query not parsing forward slash

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...