Implement the NewMatchAllQuery() function and associated types and methods in the /app/ directory to ensure all provided Go test cases related to Elasticsearch search functionalities work as expected. The required functionality includes:
Creation of Query Structure:
Define a type MatchAllQuery that represents a match-all query for Elasticsearch.
Implement a constructor function NewMatchAllQuery() that returns a new instance of MatchAllQuery.
Query Method Implementation:
Implement the necessary method(s) on the MatchAllQuery type that allows the conversion of the query into a format compatible with Elasticsearch’s search API.
Integrate with Client Search:
Ensure that the MatchAllQuery integrates seamlessly with the Elasticsearch client search capabilities. It must be able to function correctly as a query within the Search() method, specifically being callable in a chain like:
Ensure that the function supports serialization to JSON so that it can be sent as a request to Elasticsearch.
Make sure that appropriate error handling is in place if any conditions are not met during the execution of the query.
Testing Coverage:
Implement sufficient unit tests or validation checks within the implemented methods to confirm that they function according to the expected behavior demonstrated in the provided test cases.
Your implementation should conform to the coding standards of the existing codebase and should be thoroughly commented to provide clarity about the function and usage of each component.
Important: declare your solution in package elastic (the test file uses package elastic, so the implementation must use the matching package name).