- 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
- Node.js Design Patterns
- Mastering Zabbix(Second Edition)
- NLTK基礎教程:用NLTK和Python庫構建機器學習應用
- Implementing Cisco Networking Solutions
- 網絡爬蟲原理與實踐:基于C#語言
- 領域驅動設計:軟件核心復雜性應對之道(修訂版)
- Instant Lucene.NET
- Flink核心技術:源碼剖析與特性開發
- Java EE程序設計與開發實踐教程
- Microsoft Windows Identity Foundation Cookbook
- HTML5 Game Development by Example:Beginner's Guide(Second Edition)
- Web程序設計與架構
- Game Programming using Qt 5 Beginner's Guide
- MATLAB從入門到精通
- Storm Real-Time Processing Cookbook