【问题标题】:How to Query just all the documents name of index in elasticsearch如何在elasticsearch中仅查询索引的所有文档名称
【发布时间】:2019-10-08 18:39:30
【问题描述】:

PS:我是弹性搜索的新手

http://localhost:9200/indexname/domains/<mydocname>

假设我们有indexname 作为我们的索引,并且我在<mydoc> 上传了很多文档,其域名为:

http://localhost:9200/indexname/domains/google.com http://localhost:9200/indexname/domains/company.com

查看 http://localhost:9200/indexname/_count ,表示我们有 "count": 119687 数量的文档。

我只想让我的弹性搜索返回所有119687 域名的文档名称

我如何实现这一目标,是否可以在一个查询中实现这一目标?

【问题讨论】:

  • 所以你想在结果中包含 [google.com, company.com]?

标签: elasticsearch elastic-stack amazon-elastic-beanstalk


【解决方案1】:

查看示例:http://localhost:9200/indexname/domains/google.com 我假设您的 doc_type 是 domains 并且 doc id/"document name" 是 google.com

_id 是此处的文档名称,它始终是响应的一部分。您可以使用source filtering 禁用源,它只会显示如下内容:

GET indexname/_search
{
  "_source": false
}

输出

{
...
    "hits" : [
          {
            "_index" : "indexname",
            "_type" : "domains",
            "_id" : "google.com",
            "_score" : 1.0           
          }
    ]
...
}

如果documentname 是一个被映射的字段,那么您仍然可以使用源过滤来仅包含该字段。

 GET indexname/_search
 {
   "_source": ["documentname"]
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-25
    • 2020-02-14
    • 1970-01-01
    • 1970-01-01
    • 2021-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多