In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to use elasticsearch in big data search engine, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. Basic introduction
We will focus on the basic usage of elasticsearch.
two。 Noun interpretation
Before introducing the basic usage of elasticsearch, let's take a look at the meaning of nouns commonly used in elasticsearch.
Index: an index is a collection of documents that contain some similar features.
For example, you can have an index of user data, an index of product catalogs, and other indexes of regular data. An index is uniquely identified by a name (which must all be lowercase), and this name is used by the index to perform indexing, searching, updating, and deleting operations through the document.
Type (Type): a type is a category or partition in your index that allows you to store different types of documents in the same index.
For example, create one type for users and another type for blog posts.
Document: a document is the basic unit of data that can be indexed.
For example, you can create a document for a single user, a document for a single product, and other separate rules. This document is represented in JSON format, and JSON is a common format for network data exchange.
In an index or type, you can store as many documents as you want. Note that although a document belongs to an index in physical storage, the document must actually specify a type in the index.
3. Basic use
Enter the console
1. Open a browser and visit: http:// server IP:5601/
two。 Click Dev Tools in the left navigation window to enter the developer console.
Mode of accessing data:
Command: /
Explanation: request method / index name / type / document ID
Create an index:
Command: PUT / customer?pretty
Explanation: an index named "customer" is created using the PUT method. We simply append the pretty parameter to the request so that the return value is formatted with a beautiful JSON output (if the return value is in JSON format)
Command run: enter the command to create the index in the developer console.
Click the run button on the command and you can see the run result on the right.
View the index created:
Command: GET / _ cat/indices?v
Explanation: use the GET method to query the data, and the command here is to query all the indexes that currently exist.
Command run: you can see the created index customer on the right
Create a document:
Command:
Explanation: using the POST request method, put a simple customer document in the customer index with an ID of 1.
Command run: we can see from the screenshot below that a new customer document has been successfully created in the customer index. At the same time, the document has its own id, which is the id we specified when we added the document to the index.
Delete an index:
Command: DELETE / customer?pretty
Explanation: use the DELETE request method to delete the customer index and use the pretty parameter to beautify the output.
Command run: the following screenshot result means that our index has been deleted.
Add document data:
Command:
Explanation: in the above operation to create a document, we specify that the document ID is 1. In fact, when a document is indexed, the ID part is not required. If not specified, Elasticsearch will produce a random ID and then use it to index the document. The ID generated by the actual Elasticsearch (or what we explicitly specify) will be returned after the API call succeeds.
Command run: as shown in the following figure, you can see that without specifying the document ID, the random document ID will be generated and returned with the run result.
Modify document data:
Command:
Explanation: if we execute the above request again with the same document content or a different document, Elasticsearch will replace the previous document with this new document (that is, rejoin the index with the same ID).
Command run: as you can see from the following figure, the _ version field will be incremented by 1 for each operation of the data.
Delete document data:
Command: DELETE / customer/doc/1?pretty
Explanation: use the DELETE request method to delete the document with ID 1 under the customer index, and use the pretty parameter to beautify the output.
Command run: the following screenshot result means that our document data with ID 1 has been deleted.
Batch processing:
Command 1:
Explanation: call the batch method _ bulk, first create / update a document with ID 1, and then create / update a document with ID 2
Command run: successfully create documents with ID 1 and 2.
Command 2:
Explanation: call the batch method _ bulk, first update the document with ID 1, and then delete the document with ID 2.
The command runs:
About big data search engine how to use elasticsearch to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.