Perform some logic for query

Hi everyone,

I would like to ask that is it possible to query the data like one attribute MUST contain two different element. I can't find a better way to describe this so I'm going to give a simple example.

Let's say we have Alice, Bob, Charlie and David. And each of them buy different numbers of oranges and apples. So the data is like:-

  • Alice, Orange
  • Alice, Orange
  • Alice, Apple
  • Bob, Orange
  • Charlie, Apple
  • David, Orange
  • David, Apple
  • David, Apple

And I want to query that show the data whereby he/she MUST buy Orange AND Apple, and I'm expecting to see this result:

  • Alice, Orange
  • Alice, Orange
  • Alice, Apple
  • David, Orange
  • David, Apple
  • David, Apple

My end goal is to make a Horizontal Bar visualization on this whereby I have Alice and David on my Y axis, and split the chart into Orange and Apple, while showing the count of each data.

Thank you!

Hi @kvtang,
I think it's not possible right now using the standard interface of the Visualize Editor. I think you can add more logic using canvas and work on using the expression language to filter out "people" that doesn't have both Orange and Apple fruits on the created buckets

Hi @markov00,
Can I know which is the exact feature I can use in canvas to add my logic there? Cause it seems that it is pretty much for customizing the visualization only.

Hi @kvtang you can change the canvas expression to achieve that, piping together a set of canvas functions together: https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.