gpt4 book ai didi

elasticsearch - Range 和 Term 过滤器的 Elastic Search 组合

转载 作者:行者123 更新时间:2023-11-29 02:46:17 26 4
gpt4 key购买 nike

我想要一个过滤器来返回 're_max' > 100language_id = 28 的文档。我是这样做的:

{
"query": {
"filtered": {
"filter": {
"range": {
"re_max": {
"gt": 100
}
},
"term": {
"language_id": 28
}
}
}
}
}

但是好像不对。我该如何纠正?
这是错误:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed;
shardFailures {[WkgqspjtQzmPkW-YdvE1Qg][rep][0]: SearchParseException[[rep][0]:
from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"filtered": {
"filter": {
"or": [
"range":
{
"re_max": {
"gt": 100
}
},
"term":
{
"language_id": 28
}
]
}
}
}
}
]]];
nested: QueryParsingException[[rep] Failed to parse];
nested: JsonParseException[Unexpected character (':' (code 58)):
was expecting comma to separate ARRAY entries\n at [Source: [B@3d44a542; line: 6, column: 19]]; }{[WkgqspjtQzmPkW-YdvE1Qg][rep][4]:
SearchParseException[[rep][4]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"filtered": {
"filter": {
"or": [
"range":
{
"re_max": {
"gt": 100
}
},
"term":
{
"language_id": 28
}
]
}
}
}
}
]]];
nested: QueryParsingException[[rep] Failed to parse];
nested: JsonParseException[Unexpected character (':' (code 58)):
was expecting comma to separate ARRAY entries\n at [Source: [B@3d44a542; line: 6, column: 19]]; }{[WkgqspjtQzmPkW-YdvE1Qg][rep][3]:
SearchParseException[[rep][3]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"filtered": {
"filter": {
"or": [
"range":
{
"re_max": {
"gt": 100
}
},
"term":
{
"language_id": 28
}
]
}
}
}
}
]]];
nested: QueryParsingException[[rep] Failed to parse];
nested: JsonParseException[Unexpected character (':' (code 58)):
was expecting comma to separate ARRAY entries\n at [Source: [B@3d44a542; line: 6, column: 19]]; }{[WkgqspjtQzmPkW-YdvE1Qg][rep][2]:
SearchParseException[[rep][2]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"filtered": {
"filter": {
"or": [
"range":
{
"re_max": {
"gt": 100
}
},
"term":
{
"language_id": 28
}
]
}
}
}
}
]]];
nested: QueryParsingException[[rep] Failed to parse];
nested: JsonParseException[Unexpected character (':' (code 58)):
was expecting comma to separate ARRAY entries\n at [Source: [B@3d44a542; line: 6, column: 19]]; }{[WkgqspjtQzmPkW-YdvE1Qg][rep][1]:
SearchParseException[[rep][1]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"filtered": {
"filter": {
"or": [
"range":
{
"re_max": {
"gt": 100
}
},
"term":
{
"language_id": 28
}
]
}
}
}
}
]]];
nested: QueryParsingException[[rep] Failed to parse];
nested: JsonParseException[Unexpected character (':' (code 58)):
was expecting comma to separate ARRAY entries\n at [Source: [B@3d44a542; line: 6, column: 19]]; }]",
"status": 400
}

最佳答案

“过滤”查询在 2.0 和 removed 中已弃用在 5.0 中

Elasticsearch 5 和 6 filter可以使用:

{
"query": {
"bool": {
"filter": [
{ "term": { "language_id": 28 }},
{ "term": { "some_other_term": "some string value"}},
{ "range": { "created_at_timestamp": { "gt": "2015-01-01" }}}
]
}
}
}

关于elasticsearch - Range 和 Term 过滤器的 Elastic Search 组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26186023/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com