I see that the SearchRequestBuilder
has a setQuery
method which allows querying by providing the query json string. Question is, is there any drawback to this approach compared with say using QueryBuilder/FilterBuilder
which provides a different API to express the intended query?
No, there are no differences except that the QueryBuilder/FilterBuilder
might do some initial input checking and its less likely to get errors because of wrong json syntax. In ES 2.x and earlier, the queries are sent to the nodes that execute the query in json (or an equivallent binary format) anyway. With the new upcoming version 5 this will change, there the setQuery
method will only accept a QueryBuilder because the internal query serialization has changed, so if you want to plan for the future the builders are better.