Query Command with Elastic Search


We are using Axon 4.0-RC2 to implement CQRS in our project. We are planning to use Elastic Search for Query command. Can you please provide sample example on how to implement it.

Thank You for your time.

Hi Raghu,

Firstly, I’d like to suggest you’d not directly use a release candidate, but instead move over to a regular release.
Like 4.0, or better, use the latest Axon Framework release 4.1.1.

Secondly, you’re talking about a “Query Command”, which I think is mixing concepts.
From Axon’s perspective, there are three types of messages:

  1. Commands
  2. Events
  3. Queries
    Thus, they are separate from one another, not together.
    Hence, a ‘Query Command’ is not a type of message you’d be dealing with.
    You should either be discussing a query or a command instead.

What I think you mean with “Query Command” is “Query Message”.
In communication towards others, especially in your team, it’s important to be specific about this.

Thirdly, you are asking for a sample on how to leverage Elastic Search and issue Queries towards it.
From that perspective, I’d suggest you pick any regular component with a @QueryHandler annotated method in it.
That method will then call Elastic Search to request for some data.
For handling queries, I’d suggest you take a look at the Reference Guide chapter on that part, which you can find here.

The implementation specifics on how to use Elastic Search are, in my opinion, out of the scope for this User Group, as this group is about Axon, not about Elastic Search.
Regardless, if somebody has an example lying around, they are free to share this of course.