- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对elasticsearch有一个错误:
"query_parsing_exception: expected [END_OBJECT] but got [FIELD_NAME], possibly too many query clauses"
$search = [
'index' => $this->getParameter('elastic_search')['index'],
'type' => 'profile',
'body' => [
'query' => [
'bool' => [
'must' => [
'range' => [
'address.latitude' => [
'gte' => $offer->getAddress()->getLatitude() - 0.05,
'lte' => $offer->getAddress()->getLatitude() + 0.05,
],
'address.longitude' => [
'gte' => $offer->getAddress()->getLongitude() - 0.05,
'lte' => $offer->getAddress()->getLongitude() + 0.05,
],
'budget' => [
'gte' => $offer->getPrice() - 100,
'lte' => $offer->getPrice() + 100,
],
],
'bool' => [
"term" => [
"type" => 1
]
]
]
]
],
'from' => $request->get('start', 0),
'size' => $request->get('limit', 4),
'sort' => [],
'_source' => ['exclude' => 'user'],
]
];
最佳答案
每个range
查询必须位于其自己的数组元素中,并且所有bool/must
查询都必须包含在数组中。您可以这样做:
$search = [
'index' => $this->getParameter('elastic_search')['index'],
'type' => 'profile',
'body' => [
'query' => [
'bool' => [
'must' => [
[
'range' => [
'address.latitude' => [
'gte' => $offer->getAddress()->getLatitude() - 0.05,
'lte' => $offer->getAddress()->getLatitude() + 0.05,
]
]
],
[
'range' => [
'address.longitude' => [
'gte' => $offer->getAddress()->getLongitude() - 0.05,
'lte' => $offer->getAddress()->getLongitude() + 0.05,
],
],
],
[
'range' => [
'budget' => [
'gte' => $offer->getPrice() - 100,
'lte' => $offer->getPrice() + 100,
],
],
],
[
"term" => [
"type" => 1
]
]
]
]
],
'from' => $request->get('start', 0),
'size' => $request->get('limit', 4),
'sort' => [],
'_source' => ['exclude' => 'user'],
]
];
关于php - 预期[END_OBJECT],但获得了[FIELD_NAME],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40284870/
我有一个像这样的 JSON: {"aData": {"tournaments": {"new":[ {"token":"1-token", "prio":"6", "status":"inactive
我对elasticsearch有一个错误: "query_parsing_exception: expected [END_OBJECT] but got [FIELD_NAME], possibly
我正在尝试在一个 Abstact 类“Animal”上使用 Jackson 注释将 JSON 对象反序列化为 Java 对象: @JsonTypeInfo(use = JsonTypeInfo.Id.
我正在尝试使用 Jackson 将 JSON 数组反序列化为 Java 集合。这是由我昨晚 Can I instantiate a superclass and have a particular s
Elasticsearch 2.4.5 PHP 7.0 我有以下通过curl起作用的聚合查询,但是在转换为PHP时失败。我觉得自己缺少一些愚蠢/简单的东西,只是在寻找另一只眼睛 curl -XPOST
当我试图包含一个具有模糊的必须要求和几个应有的要求且其中一个是通配符的复合 bool(boolean) 查询时,我遇到了此错误消息。到目前为止,语法上的任何更改都没有帮助我解决此问题。 查询: {
我正在使用elasticsearch客户端使用constant_score和聚合进行一些搜索查询,但是它抛出异常: [parsing_exception] [constant_score] malfo
原始查询看起来像这样 { "query": { "bool": { "must": [ {
{ "from":0, "size":1000, "query": { "bool": { "must": [ {
以下JSON结构在执行查询时给我一个错误: {
我无法找出下面的查询出了什么问题。 GET website/_search { "query": { "bool": { "filter": [ {
我正在尝试编写使用 Jackson 来序列化/反序列化对象的代码。 这些对象本质上是多态的: @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = J
我在我的 Kibana 控制台中运行以下 GET 查询,由于某种原因,我在响应窗口中收到如下错误: //错误 [match] malformed query, expected [END_OBJECT
我正在尝试编写使用 Jackson 将对象序列化到 File 或从 File 反序列化的代码。 这些对象本质上是多态的。我的界面看起来像 @JsonIgnoreProperties(ignoreUnk
我是一名优秀的程序员,十分优秀!