On the elasticsearch of full-text search engine

Source: Internet
Author: User

Preface:

In the Web application or background data management, with the increase of data volume, the application of search engine especially full-text search engine is more and more urgent. Based on technology and cost considerations, we are not able to develop a search engine to meet our needs, fortunately, the industry has a number of excellent open source search engine for us to use, Elasticsearch is one of them.

Introduction:

Elasticsearch is an open source search engine based on Apache Lucene (TM). In both open source and proprietary areas, Lucene can be considered as the most advanced, best performing, and most functional search engine library in the world. However, Lucene is just a library. To use it, you have to use Java as a development language and integrate it directly into your application, and, worse, Lucene is very complex and you need to dig deeper into the knowledge of the search to understand how it works.

Elasticsearch also uses Java to develop and use Lucene as its core for all index and search functions, but it is designed to hide the complexity of lucene through a simple restful API, making full-text search simple.

However, Elasticsearch is not just lucene and full-text search, we can also describe it like this:

    • Distributed real-time file storage with each field indexed and searchable

    • Distributed real-time analytics search engine

    • Can scale to hundreds of servers, processing petabytes of structured or unstructured data

And, all of these features are integrated into a single service, and your app can interact with it through a simple restful API, a client in a variety of languages, or even a command line.

Getting started with Elasticsearch is easy. It provides a number of reasonable defaults and hides complex search engine theories for beginners. It is available out of the box (installation ready to use) and requires little learning to be used in a production environment.

Elasticsearch is licensed under Apache 2 License and can be downloaded, used and modified for free.

As you deepen your understanding of elasticsearch, you can customize Elasticsearch's advanced features according to different problem areas, all of which are configurable and flexible to configure.

Interface:

provides two sets of API interfaces based on whether or not to use Java,elasticsearch: JAVA API and RESTful API.

Two built-in clients are available for Java Api,elasticsearch:

    • node Client: The node client joins the cluster with no data node (none), in other words, it does not store any data itself, but it knows where the data is in the cluster and is able to forward the request directly to the corresponding node.

    • Transport clients (Transport client): This lighter-weight transport client is able to send requests to a remote cluster. It does not join the cluster itself, but simply forwards the request to the nodes in the cluster.


Each of the two Java clients uses the Elasticsearch transport protocol (Elasticsearch Transport Protocol) through 9300 ports and sets. The nodes in the cluster also communicate through 9300 ports. If this port is not open, your node will not be able to form a cluster.

Note:the elasticsearch version of the Java client must be the same as the other nodes in the cluster, otherwise they may not be recognized by each other.

the RESTful API is based on the HTTP protocol, with JSON as the data interaction format, available in other programming languages , communicating with Elasticsearch via Port 9200. You can use your favorite Web client, and you can even communicate with Elasticsearch via the Curl command.

basic usage of Restful APIs:

The part of the request to Elasticsearch is the same as other normal HTTP requests:

Curl-x<verb> ' <PROTOCOL>://<HOST>/<PATH>?<QUERY_STRING> '-d ' <BODY> '

which

VERB http method: GET, POST, PUT, HEAD, DELETE

PROTOCOL http or HTTPS protocol (available only when the HTTPS proxy is in front of Elasticsearch)

Host name of any node in the host Elasticsearch cluster, if it is a local node, then it is called localhost

Port Elasticsearch HTTP service, default is 9200

Query_string Some of the optional query request parameters, such as the? Pretty parameter, will return the request to a more aesthetically readable JSON data

Body a request body in JSON format (if requested)

For example: Curl-xget ' Http://192.168.0.16:9200/_count?pretty '-d ' {"Query": {"Match_all": {}}} '

Index and document concepts:

In Elasticsearch, where documents belong to one type, and these types exist in index, we can draw a simple comparison chart to compare traditional relational databases:

Columns, Tables, Databases, relational DB

Elasticsearch, Indices, Types,

Elasticsearch clusters can contain multiple indexes (indices) (databases), each of which can contain more than one type (types) (table), each containing multiple documents (lines), and then each document contains more than one field (fields) (column).

Search:

The search can be in the form of URL parameters, or you can use a DSL in the form of a JSON request body.

URL Reference: Get/index/type/_search?q=field:value

GET/index/type/id?_source=title,text

DSL (Domain specific language specific domain language):

Get/index/type/_search

{

"Query": {

"Match": {

Field:value

}

}

}


References:

Elasticsearch authoritative Guide (Chinese version): http://es.xiaoleilu.com/

This article is from the "know-how" blog, please be sure to keep this source http://xiaoliulaoding.blog.51cto.com/10306359/1713927

On the elasticsearch of full-text search engine

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.