我在使用 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/