This meant the Javascript code base would be building the complex query through something like Elasticsearch.js or by hand building the json query. There is no middle layer to hide the complex Elasticsearch queries that we were to build. Queries are built as JSON, with results pulled directly from the Elasticsearch instance through Ajax.
The first trouble we found when querying Elasticsearch for this project was the complexity of building the queries. Or at least, if we did, our automated tests would alert us before we pushed the change live for the site’s 100,000+ monthly visitors. This means after building one feature into our search, we weren't going to break it later on when we started tweaking a new feature. Because of this, we decided that it would be important to focus on building automated tests to prevent regressions. The search queries found throughout the site were complex, and we were planning to make them even more complex to achieve higher quality results. With the move to Elasticsearch, we are able to search through more than a million records in a fraction of a second. Our solution was to bring their search categories together into Elasticsearch with the goal of both speeding up search results as well as enhancing the relevance of search. Simple queries in the system could take a couple seconds or more - searching through fewer than 4000 items! This obviously was not going to work. Recently, I've worked with a client on enhancing search throughout their site.