I am getting started with ES and have a hard time understanding how to
build a query in ES to get a result set that is similar to an SQL result
set, i.e. get more fields from my documents within the facet result, like a
grid, or table, which I can then loop over in the view.
My data is similar to this:
{ order_placed: "2013-05-13 16:43",
product_id: 100,
sales_qty: 2,
payment_method: "creditcard",
country: "US",
retailer: "ABC Store"
},
{ order_placed: "2013-05-14 11:24",
product_id: 203,
sales_qty: 1,
payment_method: "cash",
country: "DE",
retailer: "XYZ Store"
},
{ order_placed: "2013-05-14 18:10",
product_id: 138,
sales_qty: 4,
payment_method: "unknown",
country: "JP",
retailer: "NPN Store"
} ... etc.
How do I do this in ES?
SELECT sum(sales_qty),country
FROM sales
WHERE product_id = 183 AND retailer = 'NPN Store'
GROUP BY country
ORDER BY sum(sales_qty) DESC;
The sum(sales_qty) should be limited to the product_id 183. I think what I
need is the term_stats facet, sort by reverse-max, and facet filter by
product_id = 183 and retailer = 'NPN Store' - I'm not sure how to put it
all together.
Basically I want to use ES like a data cube, if that makes any sense.
Pointers to documentation would be fine, as I am currently not sure what to
look for.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.