SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
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.
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Introduction
What’s
fulltext search?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Searching without index
ex. Array#grep
ex. LIKE operator in SQL
SELECT name,location
FROM Store
WHERE name LIKE '%Tokyo%';
easy, simple, but slow
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Fulltext search w/ index
Fast!!
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✓
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Demonstration: Result
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Off topic: why fast?
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Sunspot?
A client library of
Solr
for Ruby and Rails
(ActiveRecord)
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
# ...
end
end
result = Post.search do
fulltext 'best pizza'
# ...
end
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.health
client.search(q: "test")
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
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.”
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Java!!
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.
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Alternative choice
Groonga
and
Rroonga
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)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga
Realtime indexing
Read/write lock-free
Parallel updating and searching,
without penalty
Returns latest result ASAP
No transaction
No warranty for data consistency
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
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"
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"
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”✓
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Groonga
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Rroonga
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
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.
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")
# Or
Groonga::Database.open("/tmp/bookmark.db")
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")
end
end
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")
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
FYI: GrnMini
Lightweight wrapper
for Rroonga
Limited features,
but easy to use
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.
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Droonga
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Droonga
Scalable
(replication + partitioning)
Groonga compatible
HTTP interface
Client library for Ruby
(droonga-client)
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Droonga
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
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"
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Relations of services
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 Store
WHERE MATCH(name)
AGAINST('+東京' IN BOOLEAN MODE);
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 @@ '東京'"*/
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 PGroonga
for existing RDBMS
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
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/
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
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/
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
trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3
Advertisement
Serial comic
at Nikkei Linux
2015.2.18
Release
¥1728
(tax-inclusive)
Paper/Kindle

Contenu connexe

Similaire à Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-

Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
NETWAYS
 
Ruby/rails performance and profiling
Ruby/rails performance and profilingRuby/rails performance and profiling
Ruby/rails performance and profiling
Danny Guinther
 

Similaire à Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- (20)

O que tem de novo no Ruby 2.0?
O que tem de novo no Ruby 2.0?O que tem de novo no Ruby 2.0?
O que tem de novo no Ruby 2.0?
 
A rough guide to JavaScript Performance
A rough guide to JavaScript PerformanceA rough guide to JavaScript Performance
A rough guide to JavaScript Performance
 
Mroonga最新情報2016
Mroonga最新情報2016Mroonga最新情報2016
Mroonga最新情報2016
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
2017 DevSecCon ZAP Scripting Workshop
2017 DevSecCon ZAP Scripting Workshop2017 DevSecCon ZAP Scripting Workshop
2017 DevSecCon ZAP Scripting Workshop
 
DevSecCon London 2017: zap scripting workshop by Simon Bennetts
DevSecCon London 2017: zap scripting workshop by Simon BennettsDevSecCon London 2017: zap scripting workshop by Simon Bennetts
DevSecCon London 2017: zap scripting workshop by Simon Bennetts
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 
Groovy Update - Guillaume Laforge - Greach 2011
Groovy Update - Guillaume Laforge - Greach 2011Groovy Update - Guillaume Laforge - Greach 2011
Groovy Update - Guillaume Laforge - Greach 2011
 
PGroonga 2 – Make PostgreSQL rich full text search system backend!
PGroonga 2 – Make PostgreSQL rich full text search system backend!PGroonga 2 – Make PostgreSQL rich full text search system backend!
PGroonga 2 – Make PostgreSQL rich full text search system backend!
 
Ruby On Google App Engine 2nd Athens Ruby Me
Ruby On Google App Engine 2nd Athens Ruby MeRuby On Google App Engine 2nd Athens Ruby Me
Ruby On Google App Engine 2nd Athens Ruby Me
 
MongoGraph - MongoDB Meets the Semantic Web
MongoGraph - MongoDB Meets the Semantic WebMongoGraph - MongoDB Meets the Semantic Web
MongoGraph - MongoDB Meets the Semantic Web
 
5 random ruby tips
5 random ruby tips5 random ruby tips
5 random ruby tips
 
My way with Ruby
My way with RubyMy way with Ruby
My way with Ruby
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 
GroongaアプリケーションをDockerコンテナ化して配布する
GroongaアプリケーションをDockerコンテナ化して配布するGroongaアプリケーションをDockerコンテナ化して配布する
GroongaアプリケーションをDockerコンテナ化して配布する
 
Ruby/rails performance and profiling
Ruby/rails performance and profilingRuby/rails performance and profiling
Ruby/rails performance and profiling
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in Ruby
 
mri ruby gil
mri ruby gilmri ruby gil
mri ruby gil
 
Rails automatic test driven development
Rails automatic test driven developmentRails automatic test driven development
Rails automatic test driven development
 

Plus de Hiroshi Yuki

Droonga as-groonga-with-replication-droonga-as-groonga-with-replication
Droonga as-groonga-with-replication-droonga-as-groonga-with-replicationDroonga as-groonga-with-replication-droonga-as-groonga-with-replication
Droonga as-groonga-with-replication-droonga-as-groonga-with-replication
Hiroshi Yuki
 

Plus de Hiroshi Yuki (7)

Droonga as-groonga-with-replication-droonga-as-groonga-with-replication
Droonga as-groonga-with-replication-droonga-as-groonga-with-replicationDroonga as-groonga-with-replication-droonga-as-groonga-with-replication
Droonga as-groonga-with-replication-droonga-as-groonga-with-replication
 
Droonga - 分散Groongaで快適レプリケーション生活
Droonga - 分散Groongaで快適レプリケーション生活Droonga - 分散Groongaで快適レプリケーション生活
Droonga - 分散Groongaで快適レプリケーション生活
 
はじめてのDroonga
はじめてのDroongaはじめてのDroonga
はじめてのDroonga
 
Firefox/Thunderbirdを組織内でより良く使う
Firefox/Thunderbirdを組織内でより良く使うFirefox/Thunderbirdを組織内でより良く使う
Firefox/Thunderbirdを組織内でより良く使う
 
Firefoxアドオンの開発を通じて考えるようになったインタラクションデザイン
Firefoxアドオンの開発を通じて考えるようになったインタラクションデザインFirefoxアドオンの開発を通じて考えるようになったインタラクションデザイン
Firefoxアドオンの開発を通じて考えるようになったインタラクションデザイン
 
2013.02.22 OSCでの自己紹介発表資料
2013.02.22 OSCでの自己紹介発表資料2013.02.22 OSCでの自己紹介発表資料
2013.02.22 OSCでの自己紹介発表資料
 
ものすごく今更なXPCOMとXPConnectのおはなし
ものすごく今更なXPCOMとXPConnectのおはなしものすごく今更なXPCOMとXPConnectのおはなし
ものすごく今更なXPCOMとXPConnectのおはなし
 

Dernier

Dernier (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-

  • 1. 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.
  • 2. 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
  • 3. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Introduction What’s fulltext search?
  • 4. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Searching without index ex. Array#grep ex. LIKE operator in SQL SELECT name,location FROM Store WHERE name LIKE '%Tokyo%'; easy, simple, but slow
  • 5. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Fulltext search w/ index Fast!!
  • 6. 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✓
  • 7. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Demonstration: Result
  • 8. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 9. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 10. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 11. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 12. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 13. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 14. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 15. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Off topic: why fast?
  • 16. 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
  • 17. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Sunspot? A client library of Solr for Ruby and Rails (ActiveRecord)
  • 18. 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 # ... end end result = Post.search do fulltext 'best pizza' # ... end
  • 19. 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.health client.search(q: "test")
  • 20. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Relations of services
  • 21. 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.”
  • 22. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Java!!
  • 23. 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.
  • 24. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Alternative choice Groonga and Rroonga
  • 25. 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)
  • 26. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Groonga Realtime indexing Read/write lock-free Parallel updating and searching, without penalty Returns latest result ASAP No transaction No warranty for data consistency
  • 27. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Relations of services
  • 28. 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"
  • 29. 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"
  • 30. 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”✓
  • 31. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Groonga
  • 32. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Rroonga
  • 33. 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
  • 34. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Relations of services
  • 35. 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.
  • 36. 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") # Or Groonga::Database.open("/tmp/bookmark.db")
  • 37. 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") end end
  • 38. 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")
  • 39. 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
  • 40. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 FYI: GrnMini Lightweight wrapper for Rroonga Limited features, but easy to use
  • 41. 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.
  • 42. 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
  • 43. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Droonga
  • 44. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Droonga Scalable (replication + partitioning) Groonga compatible HTTP interface Client library for Ruby (droonga-client)
  • 45. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Droonga
  • 46. 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
  • 47. 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"
  • 48. 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
  • 49. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Relations of services
  • 50. 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 Store WHERE MATCH(name) AGAINST('+東京' IN BOOLEAN MODE);
  • 51. 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 @@ '東京'"*/
  • 52. 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 PGroonga for existing RDBMS
  • 53. 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
  • 54. 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/
  • 55. 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
  • 56. 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/
  • 57. 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
  • 58. trbmeetup - Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga- Powered by Rabbit 2.1.3 Advertisement Serial comic at Nikkei Linux 2015.2.18 Release ¥1728 (tax-inclusive) Paper/Kindle