ExecuteDSL
# DSL statement support
Some users expect to use the function of RestLowLevelClient to execute existing DSL statements, and realize the effect similar to that of executing DSL on xpack or es-head. So we encapsulated the implementation of DSL-API out of the box.
API
//The static dsl statement is executed without passing the index name. By default, it is the index corresponding to the current mapper.
String executeDSL(String dsl);
//Execute a static dsl statement to specify the active index.
String executeDSL(String dsl, String indexName);
1
2
3
4
2
3
4
# Use
@Test
public void testDSL() {
String DSL = "{\" size \ ":10000, \" query \ ":{\" bool \ ":{\" must \ ":[{\" $ TERM \ ":{\" title. keyword \ ":{\" value. "adjust_pure_negative\":true,\"boost\":1.0}}\"track_total_hits\":2147483647}";
String jsonResult = documentMapper.executeDSL(dsl);
//Note that after execution, it is returned in JSON format, which is parsed by the user as required.
System.out.println(jsonResult);
}
1
2
3
4
5
6
7
2
3
4
5
6
7
Help us improve this document (opens new window)
Last update: 2024/03/29