On 2/19/07, Marvin Humphrey <[EMAIL PROTECTED]> wrote:
At present, KS doesn't let you do something like that -- you have to define all your fields up front. What I'd like to do is come up with a FieldDef subclass that handles multi-dimensional data. I seem to recall that Solr had something along those lines, using prefixed field names or something. Do I recall correctly?
Yes, Solr does a simple prefix or suffix match. Solr looks up field type for a field in a Map<String,SchemaField>, and if it doesn't find it, it checks it's "dynamic fields". If a dynamic field is found, the SchemaField for it (a template) is quickly cloned, with only the name being appropriately changed. Normal field definition (the type attribute refers to another part of schema.xml): <field name="text" type="text" indexed="true" stored="false" multiValued="true"/> Dynamic field definitions: <!-- Dynamic field definitions. If a field name is not found, dynamicFields will be used if the name matches any of the patterns. RESTRICTION: the glob-like pattern in the name attribute must have a "*" only at the start or the end. EXAMPLE: name="*_i" will match any field ending in _i (like myid_i, z_i) Longer patterns will be matched first. if equal size patterns both match, the first appearing in the schema will be used. --> <dynamicField name="*_i" type="sint" indexed="true" stored="true"/> <dynamicField name="*_s" type="string" indexed="true" stored="true"/> <dynamicField name="*_l" type="slong" indexed="true" stored="true"/> <dynamicField name="*_t" type="text" indexed="true" stored="true"/> <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/> <dynamicField name="*_f" type="sfloat" indexed="true" stored="true"/> <dynamicField name="*_d" type="sdouble" indexed="true" stored="true"/> <dynamicField name="*_dt" type="date" indexed="true" stored="true"/> If I had to do it over again, I'd be tempted to further restrict the patterns so that they could be looked up from a Map rather than linearly. This hasn't proved to be a problem so far though, as the number of field-types for dynamic fields normally remains small. -Yonik --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]