ruby-on-rails - Elasticsearch : how to see the indexed data

标签 ruby-on-rails elasticsearch attr-protected

我在使用 ElasticSearch 和 Rails 时遇到问题,由于 attr_protected,一些数据没有正确索引。 Elastic Search 在哪里存储索引数据?检查实际索引数据是否错误会很有用。

使用 Tire.index('models').mapping 检查映射没有帮助,字段已列出。

最佳答案

探索 ElasticSearch 集群的最简单方法可能是使用 elasticsearch-head .

您可以通过以下方式安装它:

cd elasticsearch/
./bin/plugin install mobz/elasticsearch-head

然后(假设 ElasticSearch 已经在您的本地计算机上运行),打开浏览器窗口以:

http://localhost:9200/_plugin/head/

或者,您可以在命令行中使用 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

更新:Marvel 中的 Sense 插件

到目前为止,为 Elasticsearch 编写 curl 样式命令的最简单方法是 Sense plugin in Marvel .

它带有源突出显示、漂亮的缩进和自动完成功能。

备注:Sense was originally a standalone chrome plugin but is now part of the Marvel project .

关于ruby-on-rails - Elasticsearch : how to see the indexed data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8954785/

相关文章:

ruby-on-rails - 环境变量在 DigitalOcean 中不起作用

ruby-on-rails - Rails 3 路由问题

ruby-on-rails - 将设计确认电子邮件发送到新电子邮件而不是旧电子邮件

solr - 赋值之前引用的局部变量 'results'

elasticsearch - Elastic Search “must_not”不适用于 “filter”的字符串

ruby-on-rails - 在非 Rails Ruby 应用程序中包含 Rails 时间助手

jsf - 在JSF中何处关闭打开的客户端或使用Java垃圾收集?

ruby-on-rails - Rails 中 protected 属性的分配

python - 操作来自namedtuple()派生类的属性