42 Python distributed crawler build search engine Scrapy explaining-elasticsearch (search engine) Mget and bulk bulk operations

Source: Internet
Author: User

Note: The various operations mentioned earlier are an HTTP request operation of a data, if you want to manipulate multiple data will produce multiple requests, so there are mget and bulk bulk operations, mget and bulk bulk operation is a request can operate multiple data

1, mget batch operation (query)

Bulk operations (batch queries in the same table as the same index )

Description

#mget批量操作 (bulk query in the same table) GET _mget{  "docs": [    {      "_index": "Index name",      "_type": "Table name",      "_id": ID number    },    {      "_index": "Index name",      "_type": "Table name",      "_id": ID number    }    ]}

Code:

#mget批量操作 (bulk query in the same table) GET _mget{  "docs": [    {      "_index": "Jobbole",      "_type": "Job",      "_id": 1    }    {      "_index": "Jobbole",      "_type": "Job",      "_id": 2    }    ]}

Bulk operations (same index with different IDs in the same table bulk query)

#批量操作 (different IDs for the same table in the same index batch query) GET jobbole/job/_mget{  "IDs": [+]}

Bulk operations (batch queries in different tables of the same index)

#mget批量操作 (bulk query with different tables in the same index) GET jobbole/_mget{  "docs": [    {      "_type": "Job",      "_id": 1    },    {      "_type": "Job2",      "_id": 1    }    ]}

Bulk operations (batch queries in different tables of different indexes, equivalent to a combination of database queries)

#mget批量操作 (bulk query of different tables in different indexes) GET _mget{  "docs": [    {      "_index": "Jobbole",      "_type": "Job",      "_id": 1    },    {      "_index": "Yuxiou",      "_type": "Biao",      "_id": 2    }    ]}

2. Bulk batch operation (increase and deletion)
Bulk import can combine multiple operations, such as Index,delete,update,create, and so on. can also help to boot from one cable into another index

Bulk Bulk Operations Batch Add data

Description: Adding a piece of data is implemented by two lines of code, the first row sets the index name, table, ID of the Add data, and the second row sets the fields and values for adding data

#_bulk批量添加数据POST _bulk# Set the index name, table, id{"index" for adding data: {"_index": "Jobbole", "_type": "Job", "_id": "4"}} #设置添加数据的字段和值 {" Title ":" Crawler Development "," salary_min ": 15000," City ":" Beijing "," Company ": {" name ":" Baidu "," company_addr ":" Beijing Software Park "}," Publish_date ":" 2017-4-16 "," comments ": #设置添加数据的索引名称, table, id{" index ": {" _index ":" Jobbole "," _type ":" Job "," _id ":" 5 "}} #设置添加数据的字段和值 {" Title ": Development", "salary_min": 15000, "City": "Beijing", "Company": {"name": "Baidu", "company_addr": "Beijing Software Park"}, "Publish_date": " 2017-4-16 "," Comments ": 15}

Code:

POST _bulk{"index": {"_index": "Jobbole", "_type": "Job", "_id": "4"}}{"title": "Crawler Development", "salary_min": 15000, "City": "Beijing", "Company": {"name": "Baidu", "company_addr": "Beijing Software Park"}, "Publish_date": "2017-4-16", "Comments": 15}{"index": {"_index": " Jobbole "," _type ":" Job "," _id ":" 5 "}}{" title ":" Development "," salary_min ": 15000," City ":" Beijing "," Company ": {" name ":" Baidu "," Company _addr ":" Beijing Software Park "}," Publish_date ":" 2017-4-16 "," Comments ": 15}

Bulk Bulk operations Batch creation data (ADD)

POST _bulk{"Create": {"_index": "Jobbole", "_type": "Job", "_id": "6"}}{"title": "Development", "Salary_min": "City": "Beijing", " Company ": {" name ":" Baidu "," company_addr ":" Beijing Software Park "}," Publish_date ":" 2017-4-16 "," Comments ": 15}

Bulk Bulk Operations Bulk Delete data

POST _bulk{"Delete": {"_index": "Jobbole", "_type": "Job", "_id": "5"}}{"delete": {"_index": "Jobbole", "_type": "Job", "_ ID ":" 6 "}}

Bulk Bulk Operations Batch modification data

POST _bulk{"Update": {"_index": "Jobbole", "_type": "Job", "_id": "1"}}{"Doc": {"title": "Development", "salary_min": +, "City": " Beijing "," Company ": {" name ":" Baidu "," company_addr ":" Beijing Software Park "}," Publish_date ":" 2017-4-16 "," Comments ": 15}}

42 Python distributed crawler build search engine Scrapy explaining-elasticsearch (search engine) Mget and bulk bulk operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.