> For the complete documentation index, see [llms.txt](https://wiki.clay-wangzhi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.clay-wangzhi.com/9-elasticsearch/9.3-elasticsearch-ru-men/9.3.7-request-body-he-query-dsl-jian-jie.md).

# 9.3.7 Request Body和Query DSL简介

* 将查询语句通过HTTP Request Body发送给Elasticsearch
* Query DSL

举例

![](/files/-LoUY5Lw0aNf14X6CudP)

## 分页

* From从0开始，默认返回10个结果
* 获取靠后的翻页成本较高

![](/files/-LoUY5M2Y0qpKXkGOGBl)

## 排序

* 最好在"数字型"与"日期型"字段上排序
  * 因为对于多值类型或分析过的字段排序，系统会选一个值，无法得知该值

![](/files/-LoUY5M6TsumFFC3NHhE)

## \_source filtering

* 如果\_source没有存储，那就只返回匹配的文档的元数据
* \_source支持使用通配符\_source\["name\*","desc\*"]

![](/files/-LoUY5MBGFQxMbJ9iWLJ)

## 脚本字段

* 用例：订单中有不同的汇率，需要结合汇率对，订单价格进行排序

![](/files/-LoUY5MDv73u1V7XcRxa)

## 使用查询表达式 - Match

* 默认使用term类型，或的关系

![](/files/-LoUY5MFXW1pzwJ1XvaV)

* 可以指定操作类型为AND

![](/files/-LoUY5MHSGRO1i5k2L49)

## 短语搜索 - Match Phrase

* slop参数表示，允许各个单词之间插入的单词个数

![](/files/-LoUY5MJ0dEIncWam9tj)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.clay-wangzhi.com/9-elasticsearch/9.3-elasticsearch-ru-men/9.3.7-request-body-he-query-dsl-jian-jie.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
