SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Sphinx ,[object Object]
Почему Sphinx? ,[object Object],[object Object],[object Object]
Типы атрибутов ,[object Object],[object Object],[object Object],[object Object]
Использование атрибутов ,[object Object],[object Object],[object Object],[object Object],[object Object]
Создание индекса define_index do indexes name, :sortable => true indexes tags(:name), :as => :tags_name has id, :as => :post_id, :type => :integer has created_at, :as => :created_at, :type => :datetime, :sortable => true has author(:id), :as => :author_id, :type => :integer has author(:name), :as => :author_name, :sortable => true has tags(:id), :as => :tag_ids end
Поиск Post.search(query, :with => {:author_id => 1}) Post.search(query, :with => {:author_id => [1,2,3]}) Post.search(query, :with => {:tag_ids => 1}) Post.search(query, :with => {:created_at => 1.day.ago..Time.now}) Post.search(query, :without => {:post_id => [1,2,3]}) Post.search(query, :without => {:comments_count => 0})
Сортировка Post.search(query, :order => :created_at, :sort_mode => :asc) Post.search(query, :order => :author_name, :sort_mode => :desc) Post.search(query, :order => “created_at DESC, @relevance DESC”, :sort_mode => :extended)
Групировка результата Post.search(query, :group_by => :author_id, :group_function => :attr) Post.search(query, :group_by => :author_id, :group_function => :attr, :group_clause => “@count DESC”) Post.search(query, :group_by => :created_at, :group_function => :day, # :week, :month, :year :group_clause => “created_at DESC”) @posts.each_with_count do |post, count| ... end
Delta index define_index do ... set_property :delta => true # или set_property :delta => :datetime,  :delta_column => :created_at, :threshold => DateTime.now.zone.to_i.hours + 1.hour ... end add_column :posts, :delta, :boolean add_index :posts, :delta
Обновление дельты rake ts:in RAILS_ENV=env или indexer --config <FILE> post_delta --rotate indexer --config <FILE> --merge post_core post_delta --rotate --merge-dst-range sphinx_deleted 0 0

Weitere ähnliche Inhalte

Andere mochten auch

Алан Милц - семинар по финансовому потоку
Алан Милц - семинар по финансовому потокуАлан Милц - семинар по финансовому потоку
Алан Милц - семинар по финансовому потокуAndrew Artishchev
 
Кодабра, Фонд "Наше будущее"
Кодабра, Фонд "Наше будущее"Кодабра, Фонд "Наше будущее"
Кодабра, Фонд "Наше будущее"Dmitry Lohansky
 
Amplifr deck as it was june 2013
Amplifr deck as it was june 2013Amplifr deck as it was june 2013
Amplifr deck as it was june 2013Nate Gadgibalaev
 
Как построить Hr бренд
Как построить Hr брендКак построить Hr бренд
Как построить Hr брендKaterina Gavrilova
 
Rubinius: Ruby написанный на Ruby
Rubinius: Ruby написанный на RubyRubinius: Ruby написанный на Ruby
Rubinius: Ruby написанный на RubyIvan Samsonov
 
Работа с унаследованным кодом. Есть ли жизнь после коммита.
Работа с унаследованным кодом. Есть ли жизнь после коммита.Работа с унаследованным кодом. Есть ли жизнь после коммита.
Работа с унаследованным кодом. Есть ли жизнь после коммита.Vadim Kruchkov
 
VoxImplant eCommerce Use Cases
VoxImplant eCommerce Use CasesVoxImplant eCommerce Use Cases
VoxImplant eCommerce Use CasesAlexey Aylarov
 
FFI Library: use C extensions in Ruby
FFI Library: use C extensions in RubyFFI Library: use C extensions in Ruby
FFI Library: use C extensions in RubySasha Koss
 
Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461
Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461
Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461Alexey Mahotkin
 
Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Konstantin Haase
 
Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"
Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"
Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"Svyatoslav Vereshchak
 
Billing In SaaS applications on Rails
Billing In SaaS applications on RailsBilling In SaaS applications on Rails
Billing In SaaS applications on RailsIgor Alexandrov
 
Как мы строили аналитическую платформу на несколько миллиардов событии в месяц
Как мы строили аналитическую платформу на несколько миллиардов событии в месяцКак мы строили аналитическую платформу на несколько миллиардов событии в месяц
Как мы строили аналитическую платформу на несколько миллиардов событии в месяцMikhail Tabunov
 

Andere mochten auch (20)

Progress engine
Progress engineProgress engine
Progress engine
 
Алан Милц - семинар по финансовому потоку
Алан Милц - семинар по финансовому потокуАлан Милц - семинар по финансовому потоку
Алан Милц - семинар по финансовому потоку
 
Кодабра, Фонд "Наше будущее"
Кодабра, Фонд "Наше будущее"Кодабра, Фонд "Наше будущее"
Кодабра, Фонд "Наше будущее"
 
Amplifr deck as it was june 2013
Amplifr deck as it was june 2013Amplifr deck as it was june 2013
Amplifr deck as it was june 2013
 
Как построить Hr бренд
Как построить Hr брендКак построить Hr бренд
Как построить Hr бренд
 
Rubinius: Ruby написанный на Ruby
Rubinius: Ruby написанный на RubyRubinius: Ruby написанный на Ruby
Rubinius: Ruby написанный на Ruby
 
О ThinkWith.Me за 2 минуты
О ThinkWith.Me за 2 минутыО ThinkWith.Me за 2 минуты
О ThinkWith.Me за 2 минуты
 
Работа с унаследованным кодом. Есть ли жизнь после коммита.
Работа с унаследованным кодом. Есть ли жизнь после коммита.Работа с унаследованным кодом. Есть ли жизнь после коммита.
Работа с унаследованным кодом. Есть ли жизнь после коммита.
 
VoxImplant eCommerce Use Cases
VoxImplant eCommerce Use CasesVoxImplant eCommerce Use Cases
VoxImplant eCommerce Use Cases
 
FFI Library: use C extensions in Ruby
FFI Library: use C extensions in RubyFFI Library: use C extensions in Ruby
FFI Library: use C extensions in Ruby
 
Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461
Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461
Nastachku slideshttp://www.slideshare.net/squadette/2012-45697461
 
Отладка кода в браузере
Отладка кода в браузереОтладка кода в браузере
Отладка кода в браузере
 
Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)
 
About downloads
About downloadsAbout downloads
About downloads
 
Devcamp nodejs-2010
Devcamp nodejs-2010Devcamp nodejs-2010
Devcamp nodejs-2010
 
Education
EducationEducation
Education
 
Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"
Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"
Вебинар "Культура DevOps: основы эффективного взаимодействия IT-команд"
 
Billing In SaaS applications on Rails
Billing In SaaS applications on RailsBilling In SaaS applications on Rails
Billing In SaaS applications on Rails
 
Chef
ChefChef
Chef
 
Как мы строили аналитическую платформу на несколько миллиардов событии в месяц
Как мы строили аналитическую платформу на несколько миллиардов событии в месяцКак мы строили аналитическую платформу на несколько миллиардов событии в месяц
Как мы строили аналитическую платформу на несколько миллиардов событии в месяц
 

Ähnlich wie Дмитрий Галинский "Sphinx - как база данных"

Fazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchFazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchPedro Franceschi
 
Creating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdfCreating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdfShaiAlmog1
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchclintongormley
 
Terms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedTerms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedclintongormley
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesBenefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesAlex Nguyen
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentationguest5d87aa6
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mark Needham
 
Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Skills Matter
 
Schema design short
Schema design shortSchema design short
Schema design shortMongoDB
 
Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talkdtdannen
 
Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)MongoSF
 
Elasticsearch first-steps
Elasticsearch first-stepsElasticsearch first-steps
Elasticsearch first-stepsMatteo Moci
 
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, GermanyHarnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, GermanyAndré Ricardo Barreto de Oliveira
 
2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDBantoinegirbal
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
 
Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009Core Software Group
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNikolas Burk
 

Ähnlich wie Дмитрий Галинский "Sphinx - как база данных" (20)

Sphinx как база данных
Sphinx как база данныхSphinx как база данных
Sphinx как база данных
 
Fazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchFazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearch
 
Creating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdfCreating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdf
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearch
 
MongoDb
MongoDbMongoDb
MongoDb
 
Terms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedTerms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explained
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesBenefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#
 
Schema design short
Schema design shortSchema design short
Schema design short
 
Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talk
 
Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)
 
Elasticsearch first-steps
Elasticsearch first-stepsElasticsearch first-steps
Elasticsearch first-steps
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, GermanyHarnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
 
2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
 
Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and Prisma
 

Дмитрий Галинский "Sphinx - как база данных"

  • 1.
  • 2.
  • 3.
  • 4.
  • 5. Создание индекса define_index do indexes name, :sortable => true indexes tags(:name), :as => :tags_name has id, :as => :post_id, :type => :integer has created_at, :as => :created_at, :type => :datetime, :sortable => true has author(:id), :as => :author_id, :type => :integer has author(:name), :as => :author_name, :sortable => true has tags(:id), :as => :tag_ids end
  • 6. Поиск Post.search(query, :with => {:author_id => 1}) Post.search(query, :with => {:author_id => [1,2,3]}) Post.search(query, :with => {:tag_ids => 1}) Post.search(query, :with => {:created_at => 1.day.ago..Time.now}) Post.search(query, :without => {:post_id => [1,2,3]}) Post.search(query, :without => {:comments_count => 0})
  • 7. Сортировка Post.search(query, :order => :created_at, :sort_mode => :asc) Post.search(query, :order => :author_name, :sort_mode => :desc) Post.search(query, :order => “created_at DESC, @relevance DESC”, :sort_mode => :extended)
  • 8. Групировка результата Post.search(query, :group_by => :author_id, :group_function => :attr) Post.search(query, :group_by => :author_id, :group_function => :attr, :group_clause => “@count DESC”) Post.search(query, :group_by => :created_at, :group_function => :day, # :week, :month, :year :group_clause => “created_at DESC”) @posts.each_with_count do |post, count| ... end
  • 9. Delta index define_index do ... set_property :delta => true # или set_property :delta => :datetime, :delta_column => :created_at, :threshold => DateTime.now.zone.to_i.hours + 1.hour ... end add_column :posts, :delta, :boolean add_index :posts, :delta
  • 10. Обновление дельты rake ts:in RAILS_ENV=env или indexer --config <FILE> post_delta --rotate indexer --config <FILE> --merge post_core post_delta --rotate --merge-dst-range sphinx_deleted 0 0