Elasticsearch is primarily written in Java and is built on top of the Apache Lucene library, which is also Java-based. Java serves as the core language for Elasticsearch's development due to its robustness, portability, and strong ecosystem, enabling Elasticsearch to handle distributed architectures and high-performance indexing and searching. While Java is the foundation, users can interact with Elasticsearch using various programming languages, such as Python, Ruby, JavaScript, and more, through RESTful APIs and client libraries, making it accessible for developers across different tech stacks.