- Mastering Elasticsearch(Second Edition)
- Rafa? Ku? Marek Rogoziński
- 471字
- 2021-07-23 20:16:45
The story
As we said in the beginning of this chapter, we treat the book you are holding in your hands as a continuation of the Elasticsearch Server Second Edition book. Because of this, we would like to continue the story that we've used in that book. In general, we assume that we are implementing and running an online book store, as simple as that.
The mappings for our library
index look like the following:
{ "book" : { "_index" : { "enabled" : true }, "_id" : { "index": "not_analyzed", "store" : "yes" }, "properties" : { "author" : { "type" : "string" }, "characters" : { "type" : "string" }, "copies" : { "type" : "long", "ignore_malformed" : false }, "otitle" : { "type" : "string" }, "tags" : { "type" : "string", "index" : "not_analyzed" }, "title" : { "type" : "string" }, "year" : { "type" : "long", "ignore_malformed" : false }, "available" : { "type" : "boolean" }, "review" : { "type" : "nested", "properties" : { "nickname" : { "type" : "string" }, "text" : { "type" : "string" }, "stars" : { "type" : "integer" } } } } } }
The mappings can be found in the library.json
file provided with the book.
The data that we will use is provided with the book in the books.json
file. The example documents from that file look like the following:
{ "index": {"_index": "library", "_type": "book", "_id": "1"}} { "title": "All Quiet on the Western Front","otitle": "Im Westen nichts Neues","author": "Erich Maria Remarque","year": 1929,"characters": ["Paul B?umer", "Albert Kropp", "Haie Westhus", "Fredrich Müller", "Stanislaus Katczinsky", "Tjaden"],"tags": ["novel"],"copies": 1, "available": true, "section" : 3} { "index": {"_index": "library", "_type": "book", "_id": "2"}} { "title": "Catch-22","author": "Joseph Heller","year": 1961,"characters": ["John Yossarian", "Captain Aardvark", "Chaplain Tappman", "Colonel Cathcart", "Doctor Daneeka"],"tags": ["novel"],"copies": 6, "available" : false, "section" : 1} { "index": {"_index": "library", "_type": "book", "_id": "3"}} { "title": "The Complete Sherlock Holmes","author": "Arthur Conan Doyle","year": 1936,"characters": ["Sherlock Holmes","Dr. Watson", "G. Lestrade"],"tags": [],"copies": 0, "available" : false, "section" : 12} { "index": {"_index": "library", "_type": "book", "_id": "4"}} { "title": "Crime and Punishment","otitle": "Преступлéние и наказáние","author": "Fyodor Dostoevsky","year": 1886,"characters": ["Raskolnikov", "Sofia Semyonovna Marmeladova"],"tags": [],"copies": 0, "available" : true}
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
To create the index using the provided mappings and to index the data, we would run the following commands:
curl -XPOST 'localhost:9200/library' curl -XPUT 'localhost:9200/library/book/_mapping' -d @library.json curl -s -XPOST 'localhost:9200/_bulk' --data-binary @books.json
- 零基礎PHP學習筆記
- Ext JS Data-driven Application Design
- TestNG Beginner's Guide
- 樂高機器人設計技巧:EV3結構設計與編程指導
- Learning ASP.NET Core 2.0
- 云計算通俗講義(第3版)
- Microsoft Dynamics GP 2013 Reporting, Second Edition
- Expert Android Programming
- Asynchronous Android Programming(Second Edition)
- Mastering ROS for Robotics Programming
- 軟件測試實用教程
- OpenCV 4計算機視覺項目實戰(原書第2版)
- Python深度學習原理、算法與案例
- Test-Driven JavaScript Development
- UI設計全書(全彩)