如何在弹性搜索上使用查询字符串搜索查询字段?

发布于 2025-01-18 19:14:32 字数 202 浏览 0 评论 0原文

我想将此查询转换

GET demo-index/_search
{
 "fields": [
 "*"
 ]
}

GET demo-index/_search?fields=*

:是否可以以这种方式或类似的方式进行字段查询,而不使用 json 正文作为请求?

I want to convert this query:

GET demo-index/_search
{
 "fields": [
 "*"
 ]
}

into something like this:

GET demo-index/_search?fields=*

is it possible to do fields queries in this way or a way similar to it without using a json body for the request?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月静好 2025-01-25 19:14:32

您可以尝试使用 filter_path

如果我们有下一个返回:

{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "demo-index",
        "_type" : "_doc",
        "_id" : "32223223d3e23dd23d2x23",
        "_score" : 1.0,
        "_source" : {
          "username" : "Mike",
          "date" : "2022-04-04"
        }
      }
    ]
  }
}

并且我们想返回所有字段,我们应该按如下方式编写路径:

GET demo-index/_search?filter_path=hits.hits._source.*

如果我们想要像“用户名”这样的特定字段,我们应该将路径写为如下

GET demo-index/_search?filter_path=hits.hits._source.username

You can try with filter_path :

If we've have the next return:

{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "demo-index",
        "_type" : "_doc",
        "_id" : "32223223d3e23dd23d2x23",
        "_score" : 1.0,
        "_source" : {
          "username" : "Mike",
          "date" : "2022-04-04"
        }
      }
    ]
  }
}

And we would like to return all fields,we should write the path as follows:

GET demo-index/_search?filter_path=hits.hits._source.*

If we would like the specifics fields like "username", we should write the path as follows

GET demo-index/_search?filter_path=hits.hits._source.username
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文