Till now we
are posting data to Easticsearch, and not worrying about how each field is
mapped to specific data type. Elastic search generates dynamic mapping for us.
For example
GET
employees/employee/1
Above query
returns following data.
{ "_index": "employees", "_type": "employee", "_id": "1", "_version": 1, "found": true, "_source": { "firstName": "Tushar", "lastName": "Goyal", "hobbies": [ "Reading Novels", "Playing football" ], "age": 23, "joiningDate": { "year": 2014, "month": 1, "day": 12 } } }
You can see
mapping of any type using _mapping end point.
GET
employees/_mapping/employee
Above
statement return mapping for type employee.
{ "employees": { "mappings": { "employee": { "properties": { "age": { "type": "long" }, "firstName": { "type": "string" }, "hobbies": { "type": "string" }, "joiningDate": { "properties": { "day": { "type": "long" }, "month": { "type": "long" }, "year": { "type": "long" } } }, "lastName": { "type": "string" } } } } } }
As you
observe all the integers are mapped to long type, and all character sequences
are mapped to string type. Long type data represents exact data, string data
represent full text data.
Data in
Elasticsearch is categorized into two types.
a.
Exact
Data
b.
Full
text data
a. Exact Data
Exact data
is some thing like integers, long, float, date kind of data.
b. Full text data
It refers to
textual data. For example news articles, body of E-mail etc., Full text is
different from exact search. In exact search we can search for exact values
like get me all employees whose salary is > 25000, Get all employees whose
age is > 24, get me all students whose DOB is 02-05-1989 etc.,
In case of
full text search, we check how well this document matches to given query. For
example, when you see any news application, they suggest related articles for
given news article. They use full text search to figure out related documents.
We will discuss about Full text search in detail later.
No comments:
Post a Comment