lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: How to check if a field is a multivalue field with java
Date Wed, 22 Feb 2012 18:02:44 GMT
Hi Thomas,

With Java (from within a custom handler in Solr) you can get a handle to the IndexSchema from
the request, like so:

IndexSchema schema = req.getSchema();
SchemaField sf = schema.getField(fielaname);
boolean isMultiValued = sf.multiValued();

From within SolrJ code, you can use SolrDocument.getFieldValue() which returns an Object,
so you could do an instanceof check - if its a Collection its multivalued, else not.

Object value = sdoc.getFieldValue(fieldname);
boolean isMultiValued = value instanceof Collection;

At least this is what I do, I don't think there is a way to get a handle to the IndexSchema
object over solrj...


On Feb 22, 2012, at 9:41 AM, tschiela wrote:

> Hello,
> is there any way to check, if a field of a SolrDocument ist a multivalue
> field with java (solrj)?
> Greets
> Thomas
> --
> View this message in context:
> Sent from the Solr - User mailing list archive at

View raw message