Hi, I am currently trying to run an aggregation query to elasticsearch index to do recommendations.
Data that im pushing to elasticsearch using logstash
OrderNumber ProductName
o12345 Chicken
o55631 Peanuts
o12345 Apples
o98356 Avocado
o12345 Oranges
o31498 Peach
o12345 Grapes
As you can see above Order Number o12345 is Unique which contains all products that was purchased for that order.
After the data is passed into Elasticsearch i get the following formatted output :
"_index" : "hello",
"_type" : "logs",
"_id" : "AVmxZxg-pyZuCjD89WOe",
"_score" : 1.0,
"_source" : {
"message" : "o12345\Chicken\r",
"@version" : "1",
"@timestamp" : "2017-01-18T11:47:20.518Z",
"path" : "C:\\Elk\\logstash\\bin\\mylog.log",
"host" : "localhost",
"OrderNumber" : "o12345",
"ProductName" : "Chicken"
}, {
"_index" : "hello",
"_type" : "logs",
"_id" : "AVmxZxg-pyZuCjD89WOe",
"_score" : 1.0,
"_source" : {
"message" : "o55631\Peanuts\r",
"@version" : "1",
"@timestamp" : "2017-01-18T11:47:20.518Z",
"path" : "C:\\Elk\\logstash\\bin\\mylog.log",
"host" : "localhost",
"OrderNumber" : "o55631",
"ProductName" : "Peanuts"
I am trying to Query this data in order to get the following result :
- If I purchase "chicken" what other products was purchased with chicken. So in actual fact i need to Query the order number for chicken which is o12345 and bring back all products besides chicken.
Example
{
"query" : {
"match" : {
"ProductName" : "Chicken"
}
Now return all other products that was purchased with chicken which is Unique to o12345 which are
OrderNumber ProductName
o12345 Apples
o12345 Oranges
o12345 Grapes
Please help i am new to elastic and unsure how to formulate this query.