lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grotzke <>
Subject How to read values of a field efficiently
Date Sat, 21 Jul 2007 19:29:56 GMT

I have a custom Facet implementation that extends SimpleFacets
and overrides getTermCounts( String field ).

For the price field I calculate available ranges, for this I
have to read the values for this field. Right this looks like

    public NamedList getTermCounts( final String field ) throws IOException {
        SchemaField sf = searcher.getSchema().getField( field );
        FieldType ft = sf.getType();
        final DocValues docValues = ft.getValueSource( sf ).getValues( searcher.getReader()
        final DocIterator iter = docs.iterator();
        final TIntArrayList prices = new TIntArrayList( docs.size() );
        while (iter.hasNext()) {
           float value = docValues.floatVal(;
           prices.add( (int)value );
        // calculate ranges and return the result

This part (reading field values) takes fairly long compared
to the other fields (that use getFacetTermEnumCounts or
getFieldCacheCounts as implemented in SimpleFacets), so that
I asume that there is potential for optimization.

Fairly long: getFieldCacheCounts for the cat field takes ~70 ms
for the second request, while reading prices takes ~600 ms.

Is there a better way (in terms of performance) to determine
the values for the found docs?

Thanx in advance,

View raw message