首页 文章

验证数据库由Elasticsearch编制索引

提问于
浏览
1

我正在使用Elasticsearch来索引和搜索我的数据库......

  • 如何验证数据库是否已编入索引?

  • 如果我使用以下命令:

卷曲-XGET'http://localhost:9200/_search?q=whatever'

结果是:

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 6,
    "successful": 6,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

这些结果应该如何解释?

2 回答

  • 0

    您可以使用该命令获取数据库中存在的索引列表 . 您可以查看列表中是否存在索引 . 这表明已创建索引 .

    curl -XGET 'localhost:9200/_cat/indices?v&pretty'
    

    检查索引中是否存在任何条目 . 您可以使用此命令获取所有文档的列表 .

    curl -XGET 'localhost:9200/INDEX_NAME/_search?v&pretty'
    

    在您发布的问题中 . “_shards”{“total”:给出索引中有多少条目(此处为6)}“点击”:{“total”:为您提供与您的搜索匹配的条目(0)(0)}}

  • 0
    • 要检查您的数据库是否已编制索引,可以尝试以下命令:

    curl -XGET 'http://localhost:9200/_aliases'?pretty=true 您可以在其中查看索引列表并检查您的索引是否已编入索引 .

    • 您使用的命令基本上在所有索引中搜索关键字“whatever” . 但它无法找到任何东西 . 因此,您得到以下输出:搜索成功(由“take”描述:4,“timed_out”:false,“_ shards”:“total”:6,“成功”:6,“失败”:0})但是它没有找到任何东西(由“命中”描述:{“total”:0,“max_score”:null,“hits”:[]})

相关问题