fast fulltext search in ruby, without java -groonga, rroonga and … · trbmeetup - fast fulltext...
TRANSCRIPT
![Page 1: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/1.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
trbmeetupFast fulltext search in Ruby,
without Java-Groonga, Rroonga and Droonga-
YUKI Hiroshi ClearCode Inc.
![Page 2: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/2.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Abstract
Fulltext search?
Groonga and Rroonga
easy fulltext search in Ruby
Droonga
scalable fulltext search
![Page 3: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/3.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Introduction
What’sfulltext search?
![Page 4: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/4.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Searching without index
ex. Array#grepex. LIKE operator in SQL
SELECT name,location FROM StoreWHERE name LIKE '%Tokyo%';
easy, simple, but slow
![Page 5: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/5.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Fulltext search w/ index
Fast!!
![Page 6: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/6.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Demonstration
Methods
Array#grep (not indexed)✓
GrnMini::Array#select (indexed)✓
Data
Wikipedia(ja) pages✓
![Page 7: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/7.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Demonstration: Result
![Page 8: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/8.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 9: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/9.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 10: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/10.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 11: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/11.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 12: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/12.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 13: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/13.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 14: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/14.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 15: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/15.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
![Page 16: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/16.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
How introduce?
Major ways
Sunspot
elasticsearch-ruby
![Page 17: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/17.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Sunspot?
A client library ofSolr
for Ruby and Rails(ActiveRecord)
![Page 18: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/18.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Sunspot: Usage
class Post < ActiveRecord::Base searchable do # ... endend
result = Post.search do fulltext 'best pizza' # ...end
![Page 19: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/19.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
elasticsearch-ruby?
A client library of Elasticsearch for Ruby
client = Elasticsearch::Client.new(log: true)client.transport.reload_connections!client.cluster.healthclient.search(q: "test")
![Page 20: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/20.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
![Page 21: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/21.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
But…
Apache Solr: “built on Apache Lucene™.”
Elasticsearch: “Build on top of Apache Lucene™”
Apache Lucene: “written entirely in Java.”
![Page 22: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/22.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Java!!
![Page 23: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/23.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
In short
They require Java.
My Ruby product have to be combined with Java, just for fulltext search.
![Page 24: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/24.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Alternative choice
Groongaand
Rroonga
![Page 25: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/25.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga
Fast fulltext search engine written in C
Originally designed to search increasing huge numbers of comments in “2ch” (like Twitter)
![Page 26: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/26.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
GroongaRealtime indexing
Read/write lock-free
Parallel updating and searching, without penalty
Returns latest result ASAP
No transaction
No warranty for data consistency
![Page 27: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/27.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
![Page 28: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/28.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga’s interfaces
via command line interface
$ groonga="groonga /path/to/database/db"$ $groonga table_create --name Entries --flags TABLE_PAT_KEY --key_type ShortText$ $groonga select --table Entries --query "title:@Ruby"
![Page 29: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/29.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga’s interfaces
via HTTP
$ groonga -d --protocol http --port 10041 /path/to/database/db
$ endpoint="http://groonga:10041"$ curl "${endpoint}/d/table_create?name=Entries& flags=TABLE_PAT_KEY&key_type=ShortText"$ curl "${endpoint}/d/select?table=Entries& query=title:@Ruby"
![Page 30: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/30.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga’s interfaces
Narrowly-defined “Groonga”
CLI or server✓
libgroonga
In-process library✓
Like as “better SQLite”✓
![Page 31: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/31.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga
![Page 32: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/32.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Rroonga
![Page 33: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/33.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Rroonga
Based on libgroonga
Low-level binding of Groonga for Ruby
![Page 34: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/34.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
![Page 35: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/35.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage: Install
% sudo gem install rroonga
Groonga (libgroonga) is also installed as a part of the package.
![Page 36: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/36.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage: Prepare
require "groonga"
Groonga::Database.create(path: "/tmp/bookmark.db")# OrGroonga::Database.open("/tmp/bookmark.db")
![Page 37: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/37.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage: Schema
Groonga::Schema.define do |schema| schema.create_table("Items", type: :hash, key_type: "ShortText") do |table| table.text("title") end schema.create_table("Terms", type: :patricia_trie, normalizer: "NormalizerAuto", default_tokenizer: "TokenBigram") do |table| table.index("Items.title") endend
![Page 38: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/38.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage: Data loading
items = Groonga["Items"]items.add("http://en.wikipedia.org/wiki/Ruby", title: "Wikipedia")items.add("http://www.ruby-lang.org/", title: "Ruby")
![Page 39: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/39.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage: Fulltext search
items = Groonga["Items"]ruby_items = items.select do |record| record.title =~ "Ruby"end
![Page 40: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/40.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
FYI: GrnMini
Lightweight wrapperfor Rroonga
Limited features,but easy to use
![Page 41: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/41.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
FYI: GrnMini: Code
require "grn_mini"
GrnMini::create_or_open("/tmp/bookmarks.db")
items = GrnMini::Array.new("Items")items << { url: "http://en.wikipedia.org/wiki/Ruby", title: "Ruby - Wikipedia" }items << { url: "http://www.ruby-lang.org/", title: "Ruby Language" }
ruby_items = items.select("title:@Ruby")
Good first step to try fulltext search in your Ruby product.
![Page 42: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/42.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
For much more load…
Groonga
works with single process on a computer
Droonga
works with multiple computers constructiong a Droonga cluster
![Page 43: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/43.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Droonga
![Page 44: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/44.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Droonga
Scalable(replication + partitioning)
Groonga compatibleHTTP interface
Client library for Ruby(droonga-client)
![Page 45: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/45.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Droonga
![Page 46: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/46.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage of Droonga
Setup a Droonga node
# base="https://raw.githubusercontent.com/droonga"# curl ${base}/droonga-engine/master/install.sh | \ bash# curl ${base}/droonga-http-server/master/install.sh | \ bash# droonga-engine-catalog-generate --hosts=node0,node1,node2# service droonga-engine start# service droonga-http-server start
![Page 47: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/47.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Usage of Droonga
Fulltext search via HTTP(compatible to Groonga)
$ endpoint="http://node0:10041"$ curl "${endpoint}/d/table_create?name=Store& flags=TABLE_PAT_KEY&key_type=ShortText"
![Page 48: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/48.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
More chices
Mroonga
Add-on for MySQL/MariaDB(Bundled to MariaDB by default)
PGroonga
Add-on for PostgreSQL
![Page 49: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/49.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
![Page 50: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/50.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
SQL w/ fulltext search
Mroonga
SELECT name,location FROM StoreWHERE MATCH(name) AGAINST('+東京' IN BOOLEAN MODE);
![Page 51: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/51.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
SQL w/ fulltext search
PGroonga
SELECT name,location FROM Store WHERE name %% '東京';
SELECT name,location FROM Store WHERE name @@ '東京 OR 大阪';
SELECT name,location FROM Store WHERE name LIKE '%東京%';/* alias to "name @@ '東京'"*/
![Page 52: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/52.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Conclusion
Rroonga (and GrnMini) introduces fast fulltext search into your Ruby product instantly
Droonga for increasing load
Mroonga and PGroongafor existing RDBMS
![Page 53: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/53.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
References
Sunspot
http://sunspot.github.io/
elasticsearch-ruby
https://github.com/elasticsearch/elasticsearch-ruby
![Page 54: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/54.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
References
Apache Lucene
http://lucene.apache.org/
Apache Solr
http://lucene.apache.org/solr/
Elasticsearch
http://www.elasticsearch.org/overview/elasticsearch/
![Page 55: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/55.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
References
Groonga
http://groonga.org/
Rroonga
http://ranguba.org/
GrnMini
https://github.com/ongaeshi/grn_mini
![Page 56: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/56.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
References
Droonga
http://droonga.org/
Mroonga
http://mroonga.org/
PGroonga
http://pgroonga.github.io/
![Page 57: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/57.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
References
Comparison of PostgreSQL, pg_bigm and PGroonga
http://blog.createfield.com/entry/2015/02/03/094940
![Page 58: Fast fulltext search in Ruby, without Java -Groonga, Rroonga and … · trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3](https://reader033.vdocuments.us/reader033/viewer/2022060403/5f0eaa947e708231d440571a/html5/thumbnails/58.jpg)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Advertisement
Serial comicat Nikkei Linux
2015.2.18Release
¥1728(tax-inclusive)
Paper/Kindle