You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Ken Krugler <kk...@transpac.com> on 2013/05/11 22:10:02 UTC

Solr 4.2.1 behavior with field names that use "|" character

Hi all,

We have a fieldname that uses the "|" character to separate elements (e.g. state|city)

Up until Solr 4.x this has worked fine.

Now, when doing a query that gets distributed across shards, we get a SolrException:

SEVERE: org.apache.solr.common.SolrException: can not use FieldCache on a field which is neither indexed nor has doc values: state
	at org.apache.solr.schema.SchemaField.checkFieldCacheSource(SchemaField.java:186)
	at org.apache.solr.schema.StrField.getValueSource(StrField.java:72)
	at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:362)
	at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:68)
	at org.apache.solr.search.QParser.getQuery(QParser.java:142)
	at org.apache.solr.search.SolrReturnFields.add(SolrReturnFields.java:285)
	at org.apache.solr.search.SolrReturnFields.parseFieldList(SolrReturnFields.java:112)
	at org.apache.solr.search.SolrReturnFields.<init>(SolrReturnFields.java:98)
	at org.apache.solr.search.SolrReturnFields.<init>(SolrReturnFields.java:74)
	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:96)

The problem appears to be that the fl= state|city parameter is getting split up by the FunctionQParser, and it tries to use "state" as a field name. This actually exists, but as an ignored field (since we can just do a  q=state|city:ca|* to find all entries in California).

Is this a known issue? Is there any way to disable the parsing of field names in a field list?

Thanks,

-- Ken

--------------------------
Ken Krugler
+1 530-210-6378
http://www.scaleunlimited.com
custom big data solutions & training
Hadoop, Cascading, Cassandra & Solr






Re: Solr 4.2.1 behavior with field names that use "|" character

Posted by Jack Krupansky <ja...@basetechnology.com>.
Ken, the rule for field naming is really simple: You can use any crazy-assed 
name and all manner of special characters and spaces you want... BUT, 
anything other than a semi-strict Java name (Java "identifier but can't 
start with "$", but embedded dot and dash are allowed) is NOT guaranteed to 
work in all contexts, nor guaranteed to work in the future.

Function queries and the "fl" parameter are two great examples - both now 
support a complex syntax, and only recognize Java names.

It has always been a really bad idea to use non-indentifiers for Solr/Lucene 
field names. It is unfortunate that the "recommendation" was never 
enforced - and still isn't in all contexts.

All of that said, here's your workaround:

Wrap the crazy-assed field name in apostrophes and a "field()" function, 
e.g.,

curl http://localhost:8983/solr/update?commit=true        -H 
'Content-type:application/json' -d '
[{"id":"doc-2","us: state | city_s":"My Name"}]'

curl 
"http://localhost:8983/solr/select/?q=*:*&wt=json&indent=true&fl=id,field('us:+state+|+city_s')"

It works, but... DON'T DO IT!!! Fix your crazy-assed names!

Like: us__state__city_s

Or, even better: Two fields: "state" and "city"!

(Oh... I forgot... you're into "Big Data", so scalar fields are a no-no. 
Sigh!)

-- Jack Krupansky

-----Original Message----- 
From: Ken Krugler
Sent: Saturday, May 11, 2013 4:10 PM
To: solr-user@lucene.apache.org
Subject: Solr 4.2.1 behavior with field names that use "|" character

Hi all,

We have a fieldname that uses the "|" character to separate elements (e.g. 
state|city)

Up until Solr 4.x this has worked fine.

Now, when doing a query that gets distributed across shards, we get a 
SolrException:

SEVERE: org.apache.solr.common.SolrException: can not use FieldCache on a 
field which is neither indexed nor has doc values: state
at 
org.apache.solr.schema.SchemaField.checkFieldCacheSource(SchemaField.java:186)
at org.apache.solr.schema.StrField.getValueSource(StrField.java:72)
at 
org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:362)
at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:68)
at org.apache.solr.search.QParser.getQuery(QParser.java:142)
at org.apache.solr.search.SolrReturnFields.add(SolrReturnFields.java:285)
at 
org.apache.solr.search.SolrReturnFields.parseFieldList(SolrReturnFields.java:112)
at org.apache.solr.search.SolrReturnFields.<init>(SolrReturnFields.java:98)
at org.apache.solr.search.SolrReturnFields.<init>(SolrReturnFields.java:74)
at 
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:96)

The problem appears to be that the fl= state|city parameter is getting split 
up by the FunctionQParser, and it tries to use "state" as a field name. This 
actually exists, but as an ignored field (since we can just do a 
q=state|city:ca|* to find all entries in California).

Is this a known issue? Is there any way to disable the parsing of field 
names in a field list?

Thanks,

-- Ken

--------------------------
Ken Krugler
+1 530-210-6378
http://www.scaleunlimited.com
custom big data solutions & training
Hadoop, Cascading, Cassandra & Solr






Re: Solr 4.2.1 behavior with field names that use "|" character

Posted by Erik Hatcher <er...@gmail.com>.
Use underscore instead?   

It's really necessary for Solr to restrict the characters in a field name since they get used in various contexts and java identifier like seems reasonable, no?

	Erik


On May 11, 2013, at 16:10 , Ken Krugler wrote:

> Hi all,
> 
> We have a fieldname that uses the "|" character to separate elements (e.g. state|city)
> 
> Up until Solr 4.x this has worked fine.
> 
> Now, when doing a query that gets distributed across shards, we get a SolrException:
> 
> SEVERE: org.apache.solr.common.SolrException: can not use FieldCache on a field which is neither indexed nor has doc values: state
> 	at org.apache.solr.schema.SchemaField.checkFieldCacheSource(SchemaField.java:186)
> 	at org.apache.solr.schema.StrField.getValueSource(StrField.java:72)
> 	at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:362)
> 	at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:68)
> 	at org.apache.solr.search.QParser.getQuery(QParser.java:142)
> 	at org.apache.solr.search.SolrReturnFields.add(SolrReturnFields.java:285)
> 	at org.apache.solr.search.SolrReturnFields.parseFieldList(SolrReturnFields.java:112)
> 	at org.apache.solr.search.SolrReturnFields.<init>(SolrReturnFields.java:98)
> 	at org.apache.solr.search.SolrReturnFields.<init>(SolrReturnFields.java:74)
> 	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:96)
> 
> The problem appears to be that the fl= state|city parameter is getting split up by the FunctionQParser, and it tries to use "state" as a field name. This actually exists, but as an ignored field (since we can just do a  q=state|city:ca|* to find all entries in California).
> 
> Is this a known issue? Is there any way to disable the parsing of field names in a field list?
> 
> Thanks,
> 
> -- Ken
> 
> --------------------------
> Ken Krugler
> +1 530-210-6378
> http://www.scaleunlimited.com
> custom big data solutions & training
> Hadoop, Cascading, Cassandra & Solr
> 
> 
> 
> 
>