Elasticsearch configuration details, document metadata,

Source: Internet
Author: User

Elasticsearch configuration details, document metadata,
Directory

Returned Directory: http://www.cnblogs.com/hanyinglong/p/5464604.html

1. Elasticsearch configuration file details

A. In the previous blog, We have installed and successfully configured Elasticsearch and some plug-ins. Next we need to take a look at the Elasticseach configuration file information and some instructions.

B. first, find the installation location of Elasticsearch and jump to the config folder of elasticsearch. This folder contains two configuration files: elasticsearch. yml and logging. yml: the first is the basic configuration file of Elasticsearch, and the second is the log configuration file. Elasticsearch uses log4j to record logs, so logging. you can set the settings in yml according to the common log4j configuration folder. The following describes the configuration information in the elasticsearch. yml file.

C. The document describes the elasticsearch. yml file by writing remarks. The Elasticsearch version is 2.3.1.

C.1 cluster. name: kencery configure the cluster name of Elasticsearch. The default value is elasticsearch. Elasticsearch will automatically find the Elasticsearch cluster under the same CIDR block. If multiple clusters exist under the same CIDR block, you can use this attribute to differentiate different clusters.

C.2 node. name: "kencery-node1" cluster node name, Elasticsearch will automatically create a node name at startup, but you can also configure.

C.3 node. rack: each node in r1 can define some common attributes associated with it, which are used for filtering during later cluster fragment allocation.

C.4 path. data:/path/to/data sets the storage path of the index data. By default, it is the data folder under the root directory of Elasticsearch. You can set multiple storage paths separated by commas, yes, the data is in the file-level cross-origin location, so that more free paths are available at the time of creation, such as path. data:/path/to/data1,/path/to/data2

C.5 path. logs:/path/to/logs set the log file storage path. The default is the logs folder under the Elasticsearch root directory.

C.6 bootstrap. mlockall: true is set to true to lock the memory, because Elasticsearch is less efficient when the JVM starts swapping, so make sure that it is not swap, you can set the environment variables ES_MIN_MEN and ES_MAX_MEN to the same value and ensure that the machine has enough memory to allocate to Elasticsearch. In addition, you must allow Elasticsearch processes to lock the memory, in linux, run the 'uli-l unlimited' command.

C.7 network. host: 192.168.37.htm set the bound IP address, which can be ipv4 or ipv5. The 0.0.0.0 address is used by default, port 9200 and port 9300 are enabled for http transmission, and port 9300-9400 is enabled for communication between nodes and nodes, you can also set your own IP address.

C.8 http. port: 9200 sets the Http port for external services. The default value is 9200.

C.9 discovery. zen. ping. unicast. hosts: ["192.168.37.htm", "192.168.37.htm"] sets the initialization list of master nodes in the cluster, these nodes can be used to automatically discover the nodes that are added to the cluster (mainly used to connect machines in different CIDR blocks ).

C.10 discovery. zen. minimum_master_nodes: 3 set this parameter to ensure that the nodes in the cluster know the other N master-qualified nodes. The default value is 1. When the cluster has three more nodes, you can set a larger value (2-4)

C.11 gateway. recover_after_nodes: 3. configure data recovery when N nodes in the cluster in China are started. The default value is 1.

C.12 node. max_local_storage_nodes: 1 by default, multiple nodes can be started in the same installation path. If you want your Elasticsearch to start only one node, set it properly.

C.13 action. destructive_requires_name: true indicates whether the index can be deleted or disabled through regular expressions or _ all.

D. All the above node information exists in the configuration file, some node information configuration file is not displayed (not recommended to modify), you can view here learning: http://www.zihou.me/html/2014/01/17/9061.html

E. The above is just a brief description of some information in the Elasticsearch configuration file. For detailed configuration, see the configuration file information in the Elasticsearch you have installed.

F. For the basic concepts of Elasticsearch, see: http://blog.csdn.net/cnweike/article/details/33736429

2. Data Object Processing

A. in programming, no matter how our program is written, I believe that the ultimate goal is to serve us with data, but under many conditions, data is not just meaningless data composed of random bits and bytes. Therefore, we use associations between database nodes to represent certain things in the real world, such: in the real world, not all entity types look the same. For example, a company Employee (Employee) may only have one landline number, and another may have only one mobile phone number, some may have both, one may have an Email, and others may not. How can this problem be solved? I believe that everyone will think of object-oriented in the first time. Yes, we can use objects to process these entities with complex structures in the real world. So far, almost all development languages Support object-oriented.

B. however, when we want to store these entities, there is a problem. In most references, we use rows and columns to store data in relational databases, however, this fixed storage method leads to the absence of object flexibility. How can we store objects in the form of objects? Compared with modeling our programs around tables, we can focus more on using data and release the flexibility of objects (mongodb is a typical example of this ).

C. an Object is a language-related structure that records data in the memory. To send or store it across networks, a standard format is used to represent it, JSON (JavaScript Object Notation) is a readable way to represent objects in text. It has become a de facto standard for data exchange in the NoSql world. when an Object is serialized as JSON, it becomes a JSON document.

D. elasticsearch is a distributed Document storage engine that stores and retrieves complex data structures (serialized JSON documents) in real time. In other words, once a Document is stored in Elasticsearch, it can be retrieved on any node of the Cluster. Of course, we not only need to store data, but also need to quickly Perform Batch queries, although many NoSql solutions allow objects to be stored in the form of documents, they still need to consider how to query the data and the fields that need to be indexed for faster retrieval, in Elasticsearch, indexes are added for the data of each field by default. That is to say, each field has a reverse index for fast retrieval, in addition, unlike other databases, they can use all these reverse indexes in the same query to quickly return results.

E. Elasticsearch uses JSON (JavaScript Object Notation) as the document serialization format. JSON has been supported by most languages and has become a standard format in the NoSql field. It is concise, simple, and easy to read.

F. The source and selection of the data processing objects of Elasticsearch are briefly described above. Let's talk about document-oriented development.

3. Document-oriented development

A. What is document-oriented development? Generally, we can think that objects and documents are equivalent. However, in Elasticsearch, they are still different) it is a JSON struct (similar to hash, hashmap, Dictionary, or associated array). Objects may also contain other objects. In Elasticsearch, documents) this is a Json data serialized by the top-level structure or root object (identified by a unique Id and stored in Elasticsearch) with a special meaning ).

B. ELasticsearch is document-oriented, which means that it can store the entire object or document. However, it not only stores the entire object but also indexes the content of each document so that it can be searched, in Elasticsearch, You Can index, search, sort, and filter document object models. This is one of the reasons why Elasticsearch can perform complex full-text searches.

C. A large number of entities or objects in a program can be serialized as JSON objects containing Key-value pairs. Keys are the names of fields or properties, value can be a string, number, Boolean Type, object, array, or other special type.

D. here, I used C # To create an Employee class and declared some field attributes in it. In the subsequent articles, I will use this entity class for operations. Although the original Employee object is complex, however, its structure and object meaning have been completed in JSON, therefore, it is much easier to convert an object into JSON and index it in Elasticsearch than to do the same thing in the table structure. The object and converted JSON are as follows.

D.1 entity classes are as follows (C # can be converted to Java and other languages ):

1 using System; 2 using System. collections. generic; 3 4 namespace Common 5 {6 /// <summary> 7 // employee entity 8 /// </summary> 9 public class Emplyee10 {11 /// <summary> 12 /// employee Id13 /// </summary> 14 public string Id {get; set;} 15 16 /// <summary> 17 // employee Name 18 /// </summary> 19 public string Name {get; set ;} 20 21 /// <summary> 22 // employee Age 23 /// </summary> 24 public int Age {get; set ;} 25 26 /// <summary> 27 // whether to practice 28 /// </summary> 29 public bool IsPractice {get; set ;} 30 31 /// <summary> 32 // hobbies 33 /// </summary> 34 public string [] Interests {get; set ;} 35 36 // <summary> 37 // join company time 38 /// </summary> 39 public DateTime JoinDate {get; set ;} 40 41 // <summary> 42 // employee family information 43 // </summary> 44 public Home {get; set ;} 45 46 // <summary> 47 // employee account information 48 /// </summary> 49 public List <Accounts> Accounts {get; set ;} 50} 51 52 53 // <summary> 54 // employee family information 55 // </summary> 56 public class Home57 {58 // <summary> 59/ // latitude 60 /// </summary> 61 public double Lat {get; set;} 62 63 // <summary> 64 // longitude 65 // </summary> 66 public double Long {get; set ;} 67} 68 69 // <summary> 70 // employee Account Information 71 // </summary> 72 public class Accounts73 {74 // <summary> 75 // /Type 76 // </summary> 77 public string Type {get; set;} 78 79 // <summary> 80 // Value 81 // </summary> 82 public string Value {get; set;} 83} 84

D.2 value assignment generates a JSON object, as shown in:

E. almost all languages have corresponding modules for converting any data structure into JSON, but the details of each language are different. Elasticsearch official client will automatically serialize and deserialize JSON for us, next, let's start your Elasticsearch study journey.

4. Document metadata

A. in Elasticsearch, a document contains not only data, but also metadata (metadata). In Elasticsearch, metadata is written for each piece of data, metadata plays a very important role in Elasticsearch. The three required metadata nodes are as follows (graphic ):

Node Description
_ Index Document storage (similar to databases, which can be understood only)
_ Type Class of the object represented in the document (similar to the table in the database, this can only be understood)
_ Id Unique Identifier of the document (similar to the primary key of the table in the database, which can be understood only in this way)

  

B. _ index is similar to "Database" in a relational database. It stores and indexes associated data.

B .1 In fact, our data is stored and indexed in shards. The index is only a logical space that groups one or more shards, however, some internal details do not need to be concerned by our program. The documents are stored in the index, and the rest of the work is handled by Elasticsearch.

B .2 we will explain how to create and manage indexes in later articles. Now, to create an index using Elasticsearch, you only need to select an index name. This name must all be in lowercase and cannot start with an underscore, cannot contain commas. As shown in the class defined above, we will use company as the index name later.

C. _ type

C.1 As mentioned above, in the real world, we use objects to identify some "things". Each object belongs to a class (class, such as: Employee ), this class defines the data associated with properties or objects.

C.2 in relational databases, we often say that the same tired objects are stored in a table because they have the same structure. Of course, in Elasticsearch, we can use the same type) because their data structures are the same, each type has its own mapping or structure definition, just like columns in traditional database tables, all types of documents are stored in the same index, but the mapping of types tells Elasticsearch how different documents are epitome, it will be mentioned later.

C.3 _ type naming convention. Its name can be in upper or lower case and cannot contain underscores or commas. We will use employee as the type name later.

D. _ id is a string. When it is combined with _ index and _ type, you can uniquely identify a document in Elasticsearch. When creating a document, you can customize _ id, elasticsearch can also be automatically generated for you.

 

Through this article, we have learned about the ELasticsearch configuration file and the basic information of some documents. In the next blog, we will describe the Easticsearch communication method.

 

Every day is a little progress

If any problem exists in the article, you are welcome to point it out and I will modify it as soon as possible.

 

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.