A custom token filter may indeed be the right way to go, but an alternative is the combination of an update processor and a query preprocessor.

The update processor, which could be a JavaScript script could normalize the string into a simple integer byte count. You might also want to keep separate fields, one for the raw string and one for the final byte count. A JavaScript script would be a lot easier to develop than a custom token filter.

A query preprocessor could do two things: First, the same string to byte count normalization as the update processor, plus generate a range query. So, for example, a query for 0.5 TB could match 512 GB, 500 GB, etc, with [500000000000 TO 499999999999].

Technically, you could implement a query preprocessor as a plugin Solr search component, but if that sounds like too much effort, an application-level implementation would probably be easier to master.

-- Jack Krupansky

-----Original Message----- From: Ryan Cutter
Sent: Monday, November 11, 2013 10:18 AM
To: solr-user@lucene.apache.org
Subject: Re: Unit of dimension for solr field

I think Upayavira's suggestion of writing a filter factory fits what you're
asking for.  However, the other end of cleverness is to simple use
solr.TrieIntField and store everything in MB.  So for 1TB you'd
write 51200.  A range query for 256MB to 1GB would be field:[256 TO 1024].

Conversion from MB to your displayed unit (2TB, for example) would happen
in the application layer.  But using trie ints would be simple and
efficient.

- Ryan


On Mon, Nov 11, 2013 at 7:06 AM, eakarsu <eaka...@gmail.com> wrote:

Thanks Upayavira

It seems it needs too much work. I will have several more fields that will
have unit values.
Do we have more quicker way of implementing it?

We have Currency filed coming as default with SOLR. Can we use it?
Creating conversion rate table for each field? What I am expecting from
units is similar to currency field

Erol Akarsu




--
View this message in context:
http://lucene.472066.n3.nabble.com/Unit-of-dimension-for-solr-field-tp4100209p4100295.html
Sent from the Solr - User mailing list archive at Nabble.com.


Reply via email to