es 學習 3 DSL 總結

來源:互聯網
上載者:User
// match   全文收索 role coding  結果是包括所有 role , coding// highlight 高亮顯示 欄位// aggs  all_interests  彙總查詢// // 叢集健康   green yellow red GET /_cluster/health// 分區可以是主分區(primary shard)或者是複製分區(replica shard)。你索引中的每個文檔屬於一個單獨的主分區,所以主分區的數量決定了索引最多能儲存多少資料。// 理論上主分區能儲存的資料大小是沒有限制的,限制取決於你實際的使用方式。分區的最大容量完全取決於你的使用狀況:硬體儲存的大小、文檔的大小和複雜度、如何索引和查詢你的文檔,以及你期望的回應時間。// //複製分區只是主分區的一個副本,它可以防止硬體故障導致的資料丟失,同時可以提供讀請求,比如搜尋或者從別的shard取迴文檔。// 中繼資料//  _index 索引 類似 資料庫// _type   文檔   類型 表// _id     es 唯一標識 類型 編號// _source[查詢 返回指定欄位 欄位之間使用,分割] // http://localhost:9200/domain/domain_index/_search?_source=host,id// GET /website/blog/123?_source=title,text// // 檢查文檔是否存在 // curl -i -XHEAD http://localhost:9200/website/blog/123// // 新增// _create// PUT /website/blog/123?op_type=create  // PUT /website/blog/123/_create// // 刪除// DELETE /website/blog/123// // // 更新 // // POST /website/blog/1/_update// {//    "doc" : {//       "tags" : [ "testing" ],//       "views": 0//    }// }// 查詢  按照 id desc  // size 每頁顯示 數目  $curl_param = [        'sort'=>[                'id'=>[                    'order'=>$sort                ]        ],       'size'=>$size];// 等價於 count()方式一{    "aggs" : {        "genres" : {            "terms" : { "field" : "advertiser" }        }    }}方式二{    "aggs" : {        "genres" : {            "terms" : {             "field" : "advertiser",             "order" : { "_count" : "desc" }            },            "aggs" : {        "status" : {            "terms" : {             "field" : "status",             "order" : { "_count" : "desc" }            }                    }    }                    }    }}方式三{"query":{"bool":{"must":{"match":{"title":"c"}}}},    "aggs" : {        "genres" : {            "terms" : { "field" : "advertiser" }        }    }}//  range  範圍查詢$curl_param = [            'sort'=>[                'id'=>[                    'order'=>$sort                ]            ],            'size'=>$size,            'query'=>[                'bool'=>[                    'must'=>[                        'range'=>[                            'id'=>[                                'gt'=>$rand_id                            ]                        ]                    ]                ]            ]        ];// term  使用 等價於  sql  where id=3 的形式        $curl_param = [            'sort'=>[                'id'=>[                    'order'=>'desc'                ]            ],            'size'=>$size,            'query'=>[                'term'=>[                    'platform'=>$platform                ]            ]        ];// bool 集合查詢 // fuzzy  模糊查詢 等價於 %%$curl_param = [            'sort'=>[                'id'=>[                    'order'=>'desc'                ]            ],            'size'=>$size,            'query'=>[                'bool'=>[                    'must'=>[                        [                            'term'=>[                                'type'=>$type                            ]                        ],                        [                            'term'=>[                                'platform'=>$platform                            ]                        ]                    ],                    'should'=>[                        [                            'fuzzy'=>[                                'title'=>[                                    'value'=>$param                                ]                            ]                        ],                        [                            'fuzzy'=>[                                'domain'=>[                                    'value'=>$param                                ]                            ]                        ]                    ]                                    ]            ]        ];  // max  min 查詢  $curl_param = [            'query'=>[                'bool'=>[                    'must'=>[                        'term'=>[                            'id'=>$id                        ]                    ]                ]            ],            'aggs'=>[                'first_detected'=>[                    'min'=>[                        'field'=>'created_date'                    ]                ],                'last_detected'=>[                    'max'=>[                        'field'=>'created_date'                    ]                ]            ]        ];// groub By 查詢//  group_by_state  $curl_param = [            'query'=>[               'bool'=>[                    'must'=>[                        [                            'term'=>[                                $isfield=>1                            ]                        ],                        [                            'term'=>[                                'host'=>$host                            ]                        ]                    ]               ]            ],            'aggs'=>[                'group_by_state'=>[                    'terms'=>[                        'field'=>$field                    ]                ]            ]        ];//多欄位查詢        $curl_param = [            'sort'=>[                'id'=>[                    'order'=>'desc'                ]            ],            'query'=>[                'multi_match'=>[                    'query'=>$title,                    'type'=>'best_fields',                    'fields'=>[                        'title','domain','keywords'                    ],                    'tie_breaker'=>0.3,                    'minimum_should_match'=>'30%'                ]                            ]        ];// filter 過濾 使用$curl_param = [            'sort'=>[                    'id'=>'desc'            ],            'query'=>[                'filtered'=>[                    'filter'=>[                        'range'=>[                            'id'=>[                                'gte'=>$min_id,                                'lte'=>$max_id                            ]                        ]                    ]                ]            ]        ];  $curl_param = [            'sort'=>[                'id'=>[                    'order'=>'desc'                ]            ],            'size'=>$size,            'query'=>[                'bool'=>[                    'must'=>[                        [                            'fuzzy'=>[                                'title'=>$param                            ]                        ],                        [                            'term'=>[                                'type'=>$type                            ]                        ],                        [                            'term'=>[                                'platform'=>$platform                            ]                        ],                        [                            'term'=>[                                'shape'=>$shape                            ]                        ],                        [                            'range'=>[                                'created_date'=>[                                    'gte'=>$startTime,                                    'lt'=>$endTime                                ]                            ]                        ],                         [                            'range'=>[                                'id'=>[                                    'gte'=>$last_id                                ]                            ]                        ]                                            ]                                    ]            ]        ];   // should 使用    // foreach ($param as $key => $value) {            if($value)            {                $should_arr[] = [                    'term'=>[                        'id'=>$value                    ]                ];            }                    }        $curl_param = [            'query'=>[                'bool'=>[                    'should'=>$should_arr                ]            ]        ];

以上就介紹了 es 學習 3 DSL 總結,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.