lucene - Solr Facet Search - Get Value based on Max and Group by -
i trying price based on maximum timestamp grouped source.
the solr query have right pulls maximum timestamp each source. how can modify query pull corresponding price associated maximum timestamp?
http://localhost:6500/solr/listings/select?q=desc_t:"watch"&indent=on&rows=0&indent=true&wt=json&json.facet= { prices: { type: terms, field: source_s, facet: { max_ingestdate: "max(timestamp_dt)" } } }
this returns back:
"facets":{ "count":141211, "prices":{ "buckets":[{ "val":"a1", "count":71466, "max_ingestdate":1.505277283278e12}, { "val":"a2", "count":52415, "max_ingestdate":1.501872553356e12}, { "val":"a3", "count":7866, "max_ingestdate":1.504798294686e12},....
i want corressponding price final result should be:
"facets":{ "count":141211, "prices":{ "buckets":[{ "val":"a1", "count":71466, "max_ingestdate":1.505277283278e12, "price": 1334}, { "val":"a2", "count":52415, "max_ingestdate":1.501872553356e12, "price": 1234}, { "val":"a3", "count":7866, "max_ingestdate":1.504798294686e12 "price": 1342},...
i not sure possible grab 1 document within json facet here semi-hack use if wanted use recent price. facet source, doing, , within source facet use query facet on price in series of short time windows.
the solr call like:
http://localhost:65000/solr/listings/select?q=description_t:"watch"&indent=on&rows=0&indent=true&wt=json&json.facet= { prices: { type: terms, field: source_s, facet: { max_ingestdate: "max(timestamp_dt)", max_price: "max(price_d)", price_1: { type: query, q: "timestamp_dt:[now-1day now]", facet: { avg_price_1: "avg(price_d)" } }, price_2: { type: query, q: "timestamp_dt:[now-7day now-1day]", facet: { avg_price_2: "avg(price_d)" } }, price_3: { type: query, q: "timestamp_dt:[now-14day now-7day]", facet: { avg_price_3: "avg(price_d)" } } } } }
Comments
Post a Comment