Rob*_*bin 98 ruby-on-rails elasticsearch attr-protected
我遇到了ElasticSearch和Rails的问题,由于attr_protected,一些数据没有正确编入索引.Elastic Search在哪里存储索引数据?检查实际索引数据是否错误将很有用.
检查映射Tire.index('models').mapping没有帮助,列出该字段.
DrT*_*ech 167
探索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
到目前为止,curl为Elasticsearch 编写样式命令的最简单方法是Marvel中的Sense插件.
它带有源突出显示,非常精简和自动完成.
注意:Sense最初是一个独立的chrome插件,但现在是Marvel项目的一部分.
Jan*_*imo 34
绝对是查看索引数据的最简单方法是在浏览器中查看它.无需下载或安装.
我将假设你的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
输出看起来像这样:
请注意aliases,这意味着我们也可以在以下位置访问索引:
http://127.0.0.1:9200/products_development
第3步
导航到http://127.0.0.1:9200/products_development/_search?pretty查看您的数据:
通过对数据进行分组来解决问题 - DrTech的答案在管理这个方面时使用了方面,但是,根据Elasticsearch 1.0参考,将弃用.
Warning
Facets are deprecated and will be removed in a future release. You are encouraged to
migrate to aggregations instead.
构面由聚合替换 - 在Elasticsearch指南中以可访问的方式引入 - 将示例加载到意义中..
解决方案是相同的,除了聚合需要aggs而不是facets并且计数为0,其设置限制为最大整数   - 示例代码需要Marvel插件
# 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
            }
         ]
      }
   }
   ....
| 归档时间: | 
 | 
| 查看次数: | 94364 次 | 
| 最近记录: |