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 Mathijs Corten <m....@bedandbreakfast.eu> on 2015/01/15 10:56:34 UTC

dynamic field value in ValueSource

Hello,

At this moment i'm writing my own SOLR plugin with a custom 
ValueSourceParser and ValueSource, it's goal is to read a few fields 
from the document (For now).

I'm currently testing with the following fields:
<field name="active" type="boolean" indexed="true" stored="false" />
<field name="roomids" type="string" indexed="true" stored="false" 
multiValued="false" />
<dynamicField name="price_discount_*" type="int" indexed="true" 
stored="true" multiValued="false" />

The problem is, when i try to read the dynamic field with the following 
code it does not return the correct value (it prints '`', should be 6):

     public FunctionValues getValues(Map map, final AtomicReaderContext 
arc) throws IOException {
         final BinaryDocValues valueDynamic = 
FieldCache.DEFAULT.getTerms(arc.reader(), "price_discount_1390980_6", 
false);
         return new FunctionValues() {

             @Override
             public float floatVal(int doc) {
                 final BytesRef dynamic = valueDynamic.get(doc);
                 LOGGER.error(dynamic.utf8ToString()); // prints '`'
                 LOGGER.error(dynamic.toString()); // prints [60 8 0 0 0 6]
             }
         }
     }

When i execute the query: price_discount_1390980_6:6, it gives a result 
so i know the value of the field should be 6.

When i try to read a normal field like active or roomids it works fine:
     public FunctionValues getValues(Map map, final AtomicReaderContext 
arc) throws IOException {
         final BinaryDocValues valueActive = 
FieldCache.DEFAULT.getTerms(arc.reader(), "active", false);
         final BinaryDocValues valueActive = 
FieldCache.DEFAULT.getTerms(arc.reader(), "roomids", false);
         return new FunctionValues() {

             @Override
             public float floatVal(int doc) {
                 final BytesRef active = valueActive.get(doc);
                 LOGGER.error(active.utf8ToString());
             }
         }
     }

So my question is:
Does anyone know how to get/fix the dynamic field value? would be nice 
if it would just return 6 :P.

Hope to see an answer soon,

Mathijs