ElasticSearch: Найдется все... и быстро!

  • View
    1.059

  • Download
    6

Embed Size (px)

DESCRIPTION

По материалам конференции .NET разработчиков - http://dotnetconf.ru/materialy/elasticsearch

Text of ElasticSearch: Найдется все... и быстро!

  • 1. ElasticSearch. ! www.infinnity.ru 8- .NET dotnetconf.ru

2. 2ElasticSearch. Infinnity Solutions 3. 3ElasticSearch. 4. 4ElasticSearch. 5. 5ElasticSearch. - 6. 6ElasticSearch. 7. 7ElasticSearch. 8. 8ElasticSearch. Elasticsearch is a flexible and powerful open source, distributed, real-time search and analytics engine www.elasticsearch.org 9. 9ElasticSearch. 10. 10ElasticSearch. ElasticSearch? Mongo, Cassandra, Solr Open-Source 11. 11ElasticSearch. ElasticSearch RESTful JSON 12. 12ElasticSearch. http://ruilopes.com/elasticsearch-setup/ - windows installer https://github.com/mobz/elasticsearch-head UI (JS + REST) http://www.elastichq.org ! 13. 13ElasticSearch. Lucene (5 ) Index Type1 Type2 Type3 Index = DataBase Type = Table Document = Record Type1 Json doc Type2 Json doc Type2 Json doc Type 3 Json doc 14. 14ElasticSearch. REST Order: POST http://localhost:9200/order/ POST http://localhost:9200/order/book/ BODY: { "Author": "E.Evans", "Name": "Domain driven design" } 15. 15ElasticSearch. POST http://localhost:9200/order/book/ ( http://localhost:9200/order http://localhost:9200/) BODY : { "query":{ "bool":{ "must":[ { "query_string":{ "default_field":"book.Name", "query":" driven design" } } ] } }, "from":0, "size":50 } REST 16. 16ElasticSearch. JSON 17. 17ElasticSearch. I-4770 CPU 3.5GHz 16GB Windows 7 x64 JSON { Id : 5, Code : 4E899A40-FA60-4D51-B4F9-BCF9F7FAACEC", Value : " CC305862-BA2D-409C-A662-3D589EF7011C" } ElasticSearch 18. ROW COUNT: 1000 THREAD COUNT: 64 (8 CPUs) TOTAL Total time: 00:03:39.4040000 (219,40 sec) Average time: 219,40 ms/operation Average speed: 4,558 operation/sec INSERT Total time: 00:00:54.9130000 (54,91 sec) Average time: 54,91 ms/operation Average speed: 18,211 operation/sec UPDATE Total time: 00:01:05.4060000 (65,41 sec) Average time: 65,41 ms/operation Average speed: 15,289 operation/sec DELETE Total time: 00:00:34.2190000 (34,22 sec) Average time: 34,22 ms/operation Average speed: 29,224 operation/sec SELECT Total time: 00:01:04.8660000 (64,87 sec) Average time: 64,87 ms/operation Average speed: 15,416 operation/sec 19. 19ElasticSearch. 19 20. 20ElasticSearch. Cluster (Replica Factor = 1) Search Balancer Node MasterNode Data Node Replica 1Shard 1 Shard 2 Search Balancer Node Data Node Replica 2 DataNode Replica 3 Shard 3 Shard 4 Shard 4 Shard 5 ... 21. 21ElasticSearch. Production 3 node, 1 replica 1 node SSD GitHub: 44 amazon EC2 instance 30Tb data 8 instances 2 replica Stackoverflow.com (StackExchange) : 3 ES instance / 1 replica 22. 22ElasticSearch. Solr vs ElasticSearch http://blog.socialcast.com/realtime-search-solr-vs-elasticsearch/ 23. 23ElasticSearch. .NET ElasticSearch.NET & NEST PlainElastic https://github.com/elasticsearch/elasticsearch-net NEST: ElasticSearch Fluent- 24. 24ElasticSearch. 1. public class Person { public string Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } 2. var test = new Person() { Id 123456", LastName = " ", FirstName = " ", }; 3. client.Index(test); // Nest 4. var items = client.Search(f => f.Filter(ff => ff.Term(i => i.LastName, " "))); 25. 25ElasticSearch. 26. 26ElasticSearch. 1. Default Timeout = 1 s) 2. ElasticSearch 27. 27ElasticSearch. 1. client.Refresh() 2. Analyzers & Tokenizers 28. 28ElasticSearch. Analyzer Snowball Analyzer , . Input Data Term1 Term 2 Term 3 29. 29ElasticSearch. Standard Analyzer client.CreateIndex(IndexObject, c => c.AddMapping( m => m.MapFromAttributes().IndexAnalyzer("string_lowercase"))); 30. 30ElasticSearch. elasticsearchconfigelasticsearch.yml index: analysis: analyzer: string_lowercase: tokenizer: keyword filter: lowercase 31. 31ElasticSearch. Hint Nest ElasticSearch 32. 32ElasticSearch. ! 33. 33ElasticSearch. - ES 34. 34ElasticSearch. RESTJSON ElasticSearch 35. 35ElasticSearch. www.infinnity.ru