我遇到了ElasticSearch和Rails的问题,由于attr_protected,一些数据没有正确编入索引 . Elastic Search在哪里存储索引数据?检查实际索引数据是否错误将很有用 .
使用 Tire.index('models').mapping 检查映射没有帮助,列出了该字段 .
Tire.index('models').mapping
探索ElasticSearch集群的最简单方法可能是使用elasticsearch-head .
你可以通过这样做来安装它:
cd elasticsearch/ ./bin/plugin -install mobz/elasticsearch-head
然后(假设ElasticSearch已在您的本地计算机上运行),打开浏览器窗口:
http://localhost:9200/_plugin/head/
或者,您可以从命令行使用 curl ,例如:
curl
检查索引的映射:
curl -XGET 'http://127.0.0.1:9200/my_index/_mapping?pretty=1'
获取一些示例文档:
curl -XGET 'http://127.0.0.1:9200/my_index/_search?pretty=1'
查看存储在特定字段中的实际术语(即如何分析该字段):
curl -XGET 'http://127.0.0.1:9200/my_index/_search?pretty=1' -d ' { "facets" : { "my_terms" : { "terms" : { "size" : 50, "field" : "foo" } } } }
更多信息:http://www.elasticsearch.org/guide
到目前为止,为Elasticsearch编写 curl -style命令的最简单方法是Sense plugin in Marvel .
它带有源突出显示,非常精简和自动完成 .
注意:Sense was originally a standalone chrome plugin but is now part of the Marvel project .
绝对是查看索引数据的最简单方法是在浏览器中查看它 . No downloads or installation needed.
我假设你的elasticsearch主机是 http://127.0.0.1:9200 .
http://127.0.0.1:9200
Step 1
导航到 http://127.0.0.1:9200/_cat/indices?v 以列出您的索引 . 你会看到这样的事情:
http://127.0.0.1:9200/_cat/indices?v
Step 2
尝试访问所需的索引: http://127.0.0.1:9200/products_development_20160517164519304
http://127.0.0.1:9200/products_development_20160517164519304
输出看起来像这样:
注意 aliases ,这意味着我们也可以访问索引: http://127.0.0.1:9200/products_development
aliases
http://127.0.0.1:9200/products_development
Step 3
导航到 http://127.0.0.1:9200/products_development/_search?pretty=1 以查看您的数据:
http://127.0.0.1:9200/products_development/_search?pretty=1
ElasticSearch data browser
搜索,图表,一键设置....
通过对数据进行分组来解决问题 - DrTech的答案在管理这个问题时使用了方面但是,will be deprecated according to Elasticsearch 1.0 reference.
Warning Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
构面由聚合替换 - Introduced in an accessible manner in the Elasticsearch Guide - which loads an example into sense. .
解决方案是相同的,除了聚合需要 aggs 而不是 facets 和count of 0 which sets limit to max integer - the example code requires the Marvel Plugin
aggs
facets
# Basic aggregation GET /houses/occupier/_search?search_type=count { "aggs" : { "indexed_occupier_names" : { <= Whatever you want this to be "terms" : { "field" : "first_name", <= Name of the field you want to aggregate "size" : 0 } } } }
以下是测试它的Sense代码 - 房屋索引的示例,占用者类型和字段first_name:
DELETE /houses # Index example docs POST /houses/occupier/_bulk { "index": {}} { "first_name": "john" } { "index": {}} { "first_name": "john" } { "index": {}} { "first_name": "mark" } # Basic aggregation GET /houses/occupier/_search?search_type=count { "aggs" : { "indexed_occupier_names" : { "terms" : { "field" : "first_name", "size" : 0 } } } }
显示相关聚合代码的响应 . 索引中有两个键,John和Mark .
.... "aggregations": { "indexed_occupier_names": { "buckets": [ { "key": "john", "doc_count": 2 <= 2 documents matching }, { "key": "mark", "doc_count": 1 <= 1 document matching } ] } } ....
帮助我调试ElasticSearch的工具是ElasticHQ . 基本上,它是一个带有一些JavaScript的HTML文件 . 无需在任何地方安装,更不用说在ES本身:只需下载它,解压缩int并使用浏览器打开HTML文件 .
不确定它是ES重度用户的最佳工具 . 然而,对于急于查看参赛作品的人来说,这是非常实际的 .
如果您使用的是谷歌浏览器,那么您只需使用名为Sense的扩展名,如果您使用漫威,它也是一个工具 .
https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig
关注@JanKlimo示例,在终端上您所要做的就是:
查看所有索引: $ curl -XGET 'http://127.0.0.1:9200/_cat/indices?v'
$ 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'
products_development_20160517164519304
$ curl -XGET 'http://127.0.0.1:9200/products_development_20160517164519304/_search?pretty=1'
Kibana也是一个很好的解决方案 . 它是Elastic的数据可视化平台 . 如果安装它,它默认在端口5601上运行 .
在它提供的许多东西中 . 它有“开发工具”,我们可以在那里进行调试 .
例如,您可以使用该命令检查可用的索引
GET /_cat/indices
8 回答
探索ElasticSearch集群的最简单方法可能是使用elasticsearch-head .
你可以通过这样做来安装它:
然后(假设ElasticSearch已在您的本地计算机上运行),打开浏览器窗口:
http://localhost:9200/_plugin/head/
或者,您可以从命令行使用
curl
,例如:检查索引的映射:
获取一些示例文档:
查看存储在特定字段中的实际术语(即如何分析该字段):
更多信息:http://www.elasticsearch.org/guide
更新:Marvel中的Sense插件
到目前为止,为Elasticsearch编写
curl
-style命令的最简单方法是Sense plugin in Marvel .它带有源突出显示,非常精简和自动完成 .
注意:Sense was originally a standalone chrome plugin but is now part of the Marvel project .
绝对是查看索引数据的最简单方法是在浏览器中查看它 . No downloads or installation needed.
我假设你的elasticsearch主机是
http://127.0.0.1:9200
.Step 1
导航到
http://127.0.0.1:9200/_cat/indices?v
以列出您的索引 . 你会看到这样的事情:Step 2
尝试访问所需的索引:
http://127.0.0.1:9200/products_development_20160517164519304
输出看起来像这样:
注意
aliases
,这意味着我们也可以访问索引:http://127.0.0.1:9200/products_development
Step 3
导航到
http://127.0.0.1:9200/products_development/_search?pretty=1
以查看您的数据:ElasticSearch data browser
搜索,图表,一键设置....
聚合解决方案
通过对数据进行分组来解决问题 - DrTech的答案在管理这个问题时使用了方面但是,will be deprecated according to Elasticsearch 1.0 reference.
构面由聚合替换 - Introduced in an accessible manner in the Elasticsearch Guide - which loads an example into sense. .
简短解决方案
解决方案是相同的,除了聚合需要
aggs
而不是facets
和count of 0 which sets limit to max integer - the example code requires the Marvel Plugin完整解决方案
以下是测试它的Sense代码 - 房屋索引的示例,占用者类型和字段first_name:
回复
显示相关聚合代码的响应 . 索引中有两个键,John和Mark .
帮助我调试ElasticSearch的工具是ElasticHQ . 基本上,它是一个带有一些JavaScript的HTML文件 . 无需在任何地方安装,更不用说在ES本身:只需下载它,解压缩int并使用浏览器打开HTML文件 .
不确定它是ES重度用户的最佳工具 . 然而,对于急于查看参赛作品的人来说,这是非常实际的 .
如果您使用的是谷歌浏览器,那么您只需使用名为Sense的扩展名,如果您使用漫威,它也是一个工具 .
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'
Kibana也是一个很好的解决方案 . 它是Elastic的数据可视化平台 . 如果安装它,它默认在端口5601上运行 .
在它提供的许多东西中 . 它有“开发工具”,我们可以在那里进行调试 .
例如,您可以使用该命令检查可用的索引