Elastic Search:如何查看索引数据
我在使用 ElasticSearch 和 Rails 时遇到问题,由于 attr_protected,某些数据未正确索引。 Elastic Search 将索引数据存储在哪里?检查实际索引数据是否错误将很有用。
使用 Tire.index('models').mapping
检查映射没有帮助,该字段已列出。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
探索 ElasticSearch 集群的最简单方法可能是使用 elasticsearch-head。
您可以通过以下方式安装它:
然后(假设 ElasticSearch 已在您的本地计算机上运行),打开浏览器窗口:
http://localhost:9200/_plugin/head/
或者,您也可以从命令行使用
curl
,例如:检查索引的映射:
获取一些示例文档:
查看存储在特定字段中的实际术语(即如何分析该字段):
更多信息请参见此处:<一href="http://www.elasticsearch.org/guide" rel="nofollow noreferrer">http://www.elasticsearch.org/guide
更新:Marvel
到目前为止,为 Elasticsearch 编写
curl
风格命令的最简单方法是 Marvel 中的 Sense 插件。它具有源代码突出显示、漂亮的缩进和自动完成功能。
注意:Sense 最初是一个独立的 Chrome 插件,但现在是 Marvel 项目的一部分。
Probably the easiest way to explore your ElasticSearch cluster is to use elasticsearch-head.
You can install it by doing:
Then (assuming ElasticSearch is already running on your local machine), open a browser window to:
http://localhost:9200/_plugin/head/
Alternatively, you can just use
curl
from the command line, eg:Check the mapping for an index:
Get some sample docs:
See the actual terms stored in a particular field (ie how that field has been analyzed):
More available here: http://www.elasticsearch.org/guide
UPDATE : Sense plugin in Marvel
By far the easiest way of writing
curl
-style commands for Elasticsearch is the Sense plugin in Marvel.It comes with source highlighting, pretty indenting and autocomplete.
Note: Sense was originally a standalone chrome plugin but is now part of the Marvel project.
查看索引数据的最简单方法绝对是在浏览器中查看。 无需下载或安装。
我假设您的elasticsearch主机是
http://127.0.0.1:9200
。第 1 步
导航至
http://127.0.0.1:9200/_cat/indices?v
以列出您的索引。您会看到类似这样的内容:第 2 步
尝试访问所需的索引:
http://127.0.0.1:9200/products_development_20160517164519304
输出将如下所示:
注意
别名
,这意味着我们也可以访问以下位置的索引:http://127.0.0.1:9200/products_development
第 3 步
导航至
http://127.0.0.1:9200/products_development/_search?pretty
查看您的数据:Absolutely the easiest way to see your indexed data is to view it in your browser. No downloads or installation needed.
I'm going to assume your elasticsearch host is
http://127.0.0.1:9200
.Step 1
Navigate to
http://127.0.0.1:9200/_cat/indices?v
to list your indices. You'll see something like this:Step 2
Try accessing the desired index:
http://127.0.0.1:9200/products_development_20160517164519304
The output will look something like this:
Notice the
aliases
, meaning we can as well access the index at:http://127.0.0.1:9200/products_development
Step 3
Navigate to
http://127.0.0.1:9200/products_development/_search?pretty
to see your data:ElasticSearch 数据浏览器
搜索、图表、一键设置......
ElasticSearch data browser
Search, charts, one-click setup....
聚合解决方案
通过对数据进行分组来解决问题 - DrTech 的答案使用了方面来管理此问题,但是 将被弃用。
Facets 被聚合替换 - 在 Elasticsearch 指南中以易于理解的方式引入 - 加载了一个示例.。
简短的解决方案
该解决方案是相同的,除了聚合需要
aggs
而不是facets
并使用 计数 0 将限制设置为最大整数 - 示例代码需要 Marvel 插件完整解决方案
这是用于测试它的 Sense 代码out - 房屋索引示例,具有占用者类型和字段first_name:
响应
显示相关聚合代码的响应。索引中有两个键:John 和 Mark。
Aggregation Solution
Solving the problem by grouping the data - DrTech's answer used facets in managing this but, will be deprecated according to Elasticsearch 1.0 reference.
Facets are replaced by aggregates - Introduced in an accessible manner in the Elasticsearch Guide - which loads an example into sense..
Short Solution
The solution is the same except aggregations require
aggs
instead offacets
and with a count of 0 which sets limit to max integer - the example code requires the Marvel PluginFull Solution
Here is the Sense code to test it out - example of a houses index, with an occupier type, and a field first_name:
Response
Response showing the relevant aggregation code. With two keys in the index, John and Mark.
ElasticHQ 是一个对我调试 ElasticSearch 有很大帮助的工具。基本上,它是一个带有一些 JavaScript 的 HTML 文件。无需在任何地方安装,更不用说在 ES 本身中:只需下载它,解压缩 int 并使用浏览器打开 HTML 文件。
不确定它是 ES 重度用户的最佳工具。然而,对于那些急于查看条目的人来说,这确实很实用。
A tool that helps me a lot to debug ElasticSearch is ElasticHQ. Basically, it is an HTML file with some JavaScript. No need to install anywhere, let alone in ES itself: just download it, unzip int and open the HTML file with a browser.
Not sure it is the best tool for ES heavy users. Yet, it is really practical to whoever is in a hurry to see the entries.
Kibana 也是一个很好的解决方案。它是 Elastic 的数据可视化平台。如果安装,它默认在端口 5601 上运行。
它提供了许多功能。它有“开发工具”,我们可以在其中进行调试。
例如,您可以使用以下命令在此处检查可用索引
Kibana is also a good solution. It is a data visualization platform for Elastic.If installed it runs by default on port 5601.
Out of the many things it provides. It has "Dev Tools" where we can do your debugging.
For example you can check your available indexes here using the command
如果你使用 Google Chrome,那么你可以简单地使用这个名为 Sense 的扩展,如果你使用 Marvel,它也是一个工具。
https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig
If you are using Google Chrome then you can simply use this extension named as Sense it is also a tool if you use Marvel.
https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig
按照@JanKlimo 示例,在终端上您所要做的就是:
查看所有索引:
<代码>
$curl -XGET 'http://127.0.0.1:9200/_cat/indices?v'
查看索引
products_development_20160517164519304
的内容:<代码>
$curl -XGET 'http://127.0.0.1:9200/products_development_20160517164519304/_search?pretty=1'
Following @JanKlimo example, on terminal all you have to do is:
to see all the Index:
$ curl -XGET 'http://127.0.0.1:9200/_cat/indices?v'
to see content of Index
products_development_20160517164519304
:$ curl -XGET 'http://127.0.0.1:9200/products_development_20160517164519304/_search?pretty=1'