Facets are collected over _tokens_, so the idea of a token containing a space is kind of odd. You _might_ be able to get past the parsing error by escaping the space.
But I doubt that's what you want. I'm assuming that the field is a text field, broken up by whitespace or similar. In that case, there's no token at all that contains Student Name as that is two tokens. So I don't think this does what you intend even if you get past the parser. OTOH, if it's a string type you might get what you want by escaping. Now, all that said, what is the point here? Contains will always be more expensive as it has to iterate all of the terms to see if any match. If you _know_ the tokens, even facet.prefix would be better. Or facet.query. Or.... Best, Erick On Thu, Jul 2, 2015 at 11:56 PM, Pritam Kute <pritam.k...@hotwaxsystems.com> wrote: > Hello All, > > I am new user to solr and using solr 5.2.0 setup. I am trying to create > multiple types of facets on same field. I am filtering the facets by using " > *facet.contains*". The following is the data into field. > > roles : { > "0/Student Name/", > "1/Student Name/1000/", > "0/Center Name/", > "1/Center Name/1000/" > } > > I am trying to add facet field like following: > > query.addFacetField("{!ex=role"+i+" key=role"+i+" > facet.contains=/"+roleType+"/}roles"); > > where, roleType is iterated and it contains values "Student Name", "Center > Name" etc. and value of i is 1. > > But I am getting error as: > > org.apache.solr.search.SyntaxError: Expected identifier at pos 63 > str='{!key=role1 facet.contains=/Student Name/}roles' > > It works nicely if there is no any space in the string. i.e. if I index doc > as "1/StudentName/1000/". > > It would be great help if somebody helps me out in this issue. Please > replay if I am missing something in this. Or point me to best practice of > doing hierarchical faceting in solr. > > Thanks in advance. > > Thanks & Regards, > -- > Pritam Kute