json 如何过滤请求中opensearch API的响应?

9avjhtql  于 2023-02-26  发布在  其他
关注(0)|答案(1)|浏览(138)

我想查询一个opensearch索引,只检索hits标签中的_source。我试着在Postman中这样做:

GET: http://localhost:9200/my_index/_search?q="product1234"?format=json?filter_path=hits.hits._source

但这也让我得到了元数据和所有其他信息字段,如:

{
    "took": 17,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 44,
            "relation": "eq"
        },
        "max_score": 4.2769747,
        "hits": [
            {
                "_index": "os_fcpq_index",
                "_id": "300",
                "_score": 4.2769747,
                "_source": {...

我希望能够检索一个json,它只包含_source标记内的值,例如:

[{'_source': {'product_id': '1234'...}}]

我还看了一下OpenSearch文档,可以使用参数filter_path,但在我的示例中,我似乎遗漏了一些东西...

myzjeezk

myzjeezk1#

URL中的?太多,需要使用&而不是?分隔每个查询字符串参数

GET: http://localhost:9200/my_index/_search?q="product1234"&format=json&filter_path=hits.hits._source
                                                           ^           ^
                                                           |           |

相关问题