Hi-
 
Because sort works much faster on type 'integer', but range queries do not
work on type 'integer', I want to do this:
 
 
          <field name="a_number" type="sint" multiValued="false"
default="-1" stored="true" indexed="true" required="true">>
          <field name="a_number_sort" type="integer" multiValued="false"
stored="false" indexed="true" required="true">
...
 
        <copyField source="a_number" dest="a_number_sort" />

So, a_number_sort always contains the same data as a_number, and now we can
do a fast sort on 'a_number_sort' AND do a range query on 'a_number'. The
two will always have the same data.
. 
But, the <copyField> directive in the schema has a limitation. It will only
copy data between fields with the same type. If the two fields are a
different type, the copy is ignored. This example would require <copyField>
to translate 'sint' to 'integer'. 
 
Another case is days (not times):
 
    field day_source, type="time, defaults to TODAY, is not stored or
indexed.
    field day, type="string", required, stored & indexed, no default   
    <copyField day_source -> day/>
 
This would express the date as a string 2008-xx-xxT00:00:00Z and store that
into the day field. It is not as optimal as using '2008-xx-xx' but is still
useful for wildcards.
 
Now, let's do the sort field case. 
 
    field day_source, type="time, defaults to TODAY, is not stored or
indexed.
    field day_sort, type="integer", required, stored & indexed, no default
    <copyField day_source -> day_sort/>
 
Date is a 64-bit long and the sort fields must be integers. The field is not
stored, only indexed. This means that it has to be self-consistent but not
meaningful to the outside world.  My project does this by subtracting the
date value for jan-1-2007 from the date and use the lower 32 bits for the
sorting field. 

Is this set of cases addressed in Solr 1.3? I think using String as the
intermediate type would work in the first three cases but not for the date
-> int case. This would involve describing transformations in <copyField>
directives and that is much too involved.
 
The advantage of using <copyField> between dissimilar types is that with
defauting, you exactly duplicate the information without relying on your
feeding software. With 'date' field formula syntax, this is the only way to
have duplicate fields for different purposes.
 
Thanks for your time,
 
Lance Norskog
 
 
 
 

Reply via email to