Solr is a "document" oriented database, not a "column" oriented database.
Consider making each metric a separate document.
Dynamic fields are a powerful feature - if used in moderation, but
"hundreds" does not sound like moderation. For example, to add a new metric
you have to read and rewrite all previous metrics for that document.
-- Jack Krupansky
-----Original Message-----
From: Andy Crossen
Sent: Friday, June 27, 2014 11:10 AM
To: solr-user@lucene.apache.org
Subject: Using hundreds of dynamic fields
Hi folks,
My application requires tracking a daily performance metric for all
documents. I start tracking for an 18 month window from the time a doc is
indexed, so each doc will have ~548 of these fields. I have in my schema a
dynamic field to capture this requirement:
<dynamicField name=“metric_*” type="int" …/>
Example:
metric_2014_06_24 : 15
metric_2014_06_25 : 21
…
My application then issues a query that:
a) sorts documents by the sum of the metrics within a date range that is
variable for each query;
b) gathers stats on the metrics using the Statistics component.
With this design, the app must unfortunately:
a) construct the sort as a long list of fields within the spec’d date range
to accomplish the sum; e.g. sort=sum(metric_2014_06_24,metric_2014_06_25…)
desc
b) specify each field in the range independently to the Stats component;
e.g. stats.field=metric_2014_06_24&stats.field=metric_2014_06_25…
Am I missing a cleaner way to accomplish this given the requirements above?
Thanks for any suggestions you may have.