Search engine ElasticSearch step by step: 1 [environment Setup & amp; ElasticSearch first recognized], elasticsearch

Source: Internet
Author: User

Search engine ElasticSearch step by step: 1 [environment Setup & new knowledge of ElasticSearch], elasticsearch
1. Download ElasticSearch

A. download Java environment JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

B. Download ElasticSearch package: http://www.elasticsearch.org/overview/elkdownloads/

 

 

2. Install ElasticSearch

First, install the Java environment and check "My Computer attributes" --> "Advanced System settings" --> "advanced" --> "environment variables ",

Set the environment variable JAVA_HOME to the installed Java directory. (Don't ask why I want to install JDK, because it is written in java)

 

Decompress the ElasticSearch package and double-click elasticsearch. bat in the bin directory.

OK. When http: // localhost: 9200 is enabled, the following returned information is displayed: (if it is not running, check the Java environment as shown above)

1 {
 2     "status": 200,
 3     "name": "Krystalin",
 4     "cluster_name": "elasticsearch",
 5     "version": {
 6         "number": "1.4.1",
 7         "build_hash": "89d3241d670db65f994242c8e8383b169779e2d4",
 8         "build_timestamp": "2014-11-26T15:49:29Z",
 9         "build_snapshot": false,
10         "lucene_version": "4.10.2"
11     },
12     "tagline": "You Know, for Search"
13 }


I returned a bunch of things. It doesn't matter if I don't know what it means. We will learn it later.

 

3. Search

Now that the search engine is running, let's tease him.

ElasticSearch provides a complete set of restful APIs for indexing, Mapping, and searching. To use the APIS provided by ElasticSearch, first ensure that you have an Http packet sending tool (for example, Fiddler), and then you need to have some data for the search. (You have sorted it out. Download jokeData.rar)

REST stands for "Representative State Transfer", a resource-oriented architecture.
The use of Http verbs: GET, POST, PUT, DELETE to promote CRUD of resources is encouraged.
Each resource has a uniquely determined Uri address 

 

Step 1: Create an index

Open the "Composer" tag in Fiddler,

Select the POST request method, fill in http: // localhost: 9200/joke/normal/_ bulk in the address bar, and add the content in the file to the Body.

200 is returned. Execution successful.



Step 2: Search

Enter in the browser (or use GET request in Fiddler): http: // localhost: 9200/joke/normal/_ search? Q = today

The returned results are as follows:

{"Took": 35, "timed_out": false, "_ shards": {"total": 5, "successful": 5, "failed": 0 }, "hits": {"total": 76, "max_score": 0.5989393, "hits": [{"_ index": "joke", "_ type ": "normal", "_ id": "9", "_ score": 0.5989393, "_ source": {"Id": 9, "Data ":"★Tired {br} A man said to a woman, "Are your legs tired today ?" {Br} WOMAN: "why "? {Br} Man: "Because, you have been running in my mind for a day, can you leave me tired "? "}}, {" _ Index ":" joke "," _ type ":" normal "," _ id ":" 153 "," _ score ": 0.42523623, "_ source": {"Id": 153, "Data ":"★What does he want to do? {br} the couple played bridge for several hours. Then one of the men stood up and went to the bathroom. I sighed with his wife and said, "This evening, I am the first time to understand what he wants ." ".........View Code

 

 

4. Summary

So far, our search engine can search for data as required, but there is still a gap between them.

For example, word segmentation is not very accurate. How to query the next page of a page ......

We will solve the above problems and learn more.

 

[Main directory ]]


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.