gpt4 book ai didi

带有 query_string 和范围的 Elasticsearch

转载 作者:行者123 更新时间:2023-12-02 08:28:36 29 4
gpt4 key购买 nike

我试图得到一个大于 X 且字段等于 Y 的结果。我试过这个:

{
"sort": {
"datapublicacao": "desc"
},
"query": {
"query_string": {
"query": "fullslug:noticia"
},
"range": {
"id": {
"gt": "145890"
}
}
}
}

但是出现如下错误:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[PkbOJvspSO-yk_8dRMmxcg][jornal.jurid][2]: SearchParseException[[jornal.jurid][2]: query[fullslug:noticia],from[-1],size[-1],sort[<custom:\"datapublicacao\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@4105c103>!]: Parse Failure [Failed to parse source [{\n \"sort\": {\n \"datapublicacao\": \"desc\"\n },\n \"query\": {\n \"query_string\": {\n \"query\": \"fullslug:noticia\"\n },\n \"range\": {\n \"id\": {\n \"gt\": \"145890\"\n }\n }\n }\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"range\"]; }{[PkbOJvspSO-yk_8dRMmxcg][jornal.jurid][3]: SearchParseException[[jornal.jurid][3]: query[fullslug:noticia],from[-1],size[-1],sort[<custom:\"datapublicacao\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@32ef6244>!]: Parse Failure [Failed to parse source [{\n \"sort\": {\n \"datapublicacao\": \"desc\"\n },\n \"query\": {\n \"query_string\": {\n \"query\": \"fullslug:noticia\"\n },\n \"range\": {\n \"id\": {\n \"gt\": \"145890\"\n }\n }\n }\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"range\"]; }{[PkbOJvspSO-yk_8dRMmxcg][jornal.jurid][0]: SearchParseException[[jornal.jurid][0]: query[fullslug:noticia],from[-1],size[-1],sort[<custom:\"datapublicacao\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1534ed83>!]: Parse Failure [Failed to parse source [{\n \"sort\": {\n \"datapublicacao\": \"desc\"\n },\n \"query\": {\n \"query_string\": {\n \"query\": \"fullslug:noticia\"\n },\n \"range\": {\n \"id\": {\n \"gt\": \"145890\"\n }\n }\n }\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"range\"]; }{[PkbOJvspSO-yk_8dRMmxcg][jornal.jurid][1]: SearchParseException[[jornal.jurid][1]: query[fullslug:noticia],from[-1],size[-1],sort[<custom:\"datapublicacao\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@21c787c>!]: Parse Failure [Failed to parse source [{\n \"sort\": {\n \"datapublicacao\": \"desc\"\n },\n \"query\": {\n \"query_string\": {\n \"query\": \"fullslug:noticia\"\n },\n \"range\": {\n \"id\": {\n \"gt\": \"145890\"\n }\n }\n }\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"range\"]; }{[PkbOJvspSO-yk_8dRMmxcg][jornal.jurid][4]: SearchParseException[[jornal.jurid][4]: query[fullslug:noticia],from[-1],size[-1],sort[<custom:\"datapublicacao\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@45d53e55>!]: Parse Failure [Failed to parse source [{\n \"sort\": {\n \"datapublicacao\": \"desc\"\n },\n \"query\": {\n \"query_string\": {\n \"query\": \"fullslug:noticia\"\n },\n \"range\": {\n \"id\": {\n \"gt\": \"145890\"\n }\n }\n }\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"range\"]; }]",
"status": 400
}

如果我只使用 query_string 或范围进行查询,它可以工作,但对它们都不起作用。

最佳答案

使用 Elasticsearch bool search如下

{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "fullslug:noticia"
}
},
{
"range": {
"id": {
"gte": 145890
}
}
}
]
}
}
}
},
"sort": {
"datapublicacao": "desc"
}
}

关于带有 query_string 和范围的 Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29676380/

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