lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathijs Corten <m.cor...@bedandbreakfast.eu>
Subject dynamic field value in ValueSource
Date Thu, 15 Jan 2015 09:56:34 GMT
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

Mime
View raw message