Hello, I am having trouble finding Elasticsearch Java code that will accept a full QueryDSL object as a String. My basic use case is as follows:
Our UI code is set up to generate QueryDSL based on user input and user searches
The search does not call Elasticsearch directly. Instead, the search calls an internal API that first does some user authentication and other validations before calling Elasticsearch
Based on the authentication/validation, the API may also need to add additional search criteria to the QueryDSL and then call Elasticsearch
I checked the Elasticsearch documentation and searched forum threads, and also attempted to draft up this code, but I cannot find anywhere in the Elasticsearch libraries (including spring-data-elasticsearch) that allows for direct handling or manipulation of a QueryDSL String object. Does such a class/method exist? For example, I was hoping that QueryBuilder would have such a function as:
QueryBuilders.fullDslQuery(myQueryDsl);
where I could feed this String and get results:
{
"query": {
"match_all": {}
}
}
I found a partial answer: QueryBuilders.wrapperQuery() accepts a full query as input. The problem is that it only accepts query data, and does not accept pagination entries nor aggregations. Using this call as an example:
{
"from" : 0, "size" : 20,
"query": { "match": { "account.id": "123" } }
}
QueryBuilder cannot handle the pagination values, because wrapperQuery() assumes you are inside the "query" method already. The java code for the above function is therefore: QueryBuilders.wrapperQuery("\"query\": { \"match\": { \"account.id\": \"123\" } }")
Is there a way to accept the exact text from cURL? I am hoping that the pagination values can be sent from the client end without having to handle it on the Java side.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.