SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
PinQAでのMongoDB活用事例


          NTT レゾナント株式会社
          近藤 美沙
サービス紹介
場所を指定して質問
場所を指定して回答
質問は範囲=矩形
回答はポイント=点
MongoDBを使ってます



PinQAは位置情報ベースのQ&Aサービスです。
                http://pinqa.com/
MongoDBとは
● JSONをベースとしたスキーマレスなデー
  タモデル
● フェイルオーバー構成が選択可能
● B-treeインデックスをサポートする高速な
  クエリ
● 分散データベース
● 二次元の地理空間のインデックス
  (geospatial index)
   PinQAは位置情報ベースのQ&Aサービスです。
                   http://pinqa.com/
色々特徴がありますが



PinQAは位置情報ベースのQ&Aサービスです。
                http://pinqa.com/
本日のお題は



PinQAは位置情報ベースのQ&Aサービスです。
                http://pinqa.com/
二次元地理空間のインデックス
     (geospatial index)


 PinQAは位置情報ベースのQ&Aサービスです。
                 http://pinqa.com/
地理空間インデックスとは
位置情報をベースにしたクエリのためのインデックス
例)神保町駅から半径300m以内にある喫茶店を検索
インデックスを作る前に
● db #データベース
● squares # コレクション
データベースはその名の通りデータベース、コレクション
の集合体。

コレクションというのは、RDBでいうところのテーブルに近
いもの。ドキュメントの集合体。



    PinQAは位置情報ベースのQ&Aサービスです。
                    http://pinqa.com/
地理空間インデックスの作り方
● MongoDB側で直接叩く場合
$ db.squares.ensureIndex({latlng:"2d"})

● Mongoid側で行う場合
$ Mongoid.master.collections.each do |c|
$ if c.name == "squares"
$     c.create_index([['latlng', Mongo::GEO2D]])
$ end
$ end


       PinQAは位置情報ベースのQ&Aサービスです。
                       http://pinqa.com/
PinQAでの活用事例



PinQAは位置情報ベースのQ&Aサービスです。
                http://pinqa.com/
●質問データをMongoDBに投入

●MongoDBに入ってしまえば



   PinQAは位置情報ベースのQ&Aサービスです。
                   http://pinqa.com/
within(box)=矩形内の質問取得
within(box)
$ def self.find_in_bounds(hash)
$   self.where(:latlng.within =>
$          { "$box" => [
$                      [hash[:southwest_lat],
$                        hash[:southwest_lng]],
$                      [hash[:northeast_lat],
$                        hash[:northeast_lng]]
$                      ]
$            }
$    )
$ end
$
within(center)=円形内の質問取得
within(center)
$ def self.find_in_circle(hash)
$   self.where(:latlng.within =>
$          { "$center" =>[[hash[:lat],hash[:lng]],
$                         hash[:distance]
$          }
$    )
$ end
$



         PinQAは位置情報ベースのQ&Aサービスです。
                         http://pinqa.com/
near = 近くにある質問を取得
      基点から近い順に取得
near
$ def self.find(hash)
$   self.where(:latlng.near => [hash[:lat], hash[:lng]])
$ end
$




         PinQAは位置情報ベースのQ&Aサービスです。
                         http://pinqa.com/
geoNear
$ db.runCommand( {geoNear : "squares",
$                 near : [lat,lng], num : 10} );


Mongoid (1.9.1)ではgeoNearはサポートされてない模
様。

別途拡張ライブラリが必要。



         PinQAは位置情報ベースのQ&Aサービスです。
                         http://pinqa.com/
geoNear = near + オプション
・結果に詳細情報が付加される
地理空間インデックスでできること
● near:近くのデータを取得

● within:領域内のデータを取得 
          boxとcirculeがある。

● geoNear:near+詳細情報の取得



    PinQAは位置情報ベースのQ&Aサービスです。
                    http://pinqa.com/
最後にちょっと宣伝




PinQAは位置情報ベースのQ&Aサービスです。
                http://pinqa.com/
Comming soon

Weitere ähnliche Inhalte

Andere mochten auch

Introduction git
Introduction gitIntroduction git
Introduction gitMisa Kondo
 
バージョン管理
バージョン管理バージョン管理
バージョン管理Misa Kondo
 
Git introduction2
Git introduction2Git introduction2
Git introduction2Misa Kondo
 
Application Release Utilizing MCollective
Application Release  Utilizing MCollectiveApplication Release  Utilizing MCollective
Application Release Utilizing MCollectiveMisa Kondo
 
Challenge ogx gip 2012.1
Challenge ogx gip 2012.1Challenge ogx gip 2012.1
Challenge ogx gip 2012.1Leotornel
 
Chefのはじめの一歩
Chefのはじめの一歩Chefのはじめの一歩
Chefのはじめの一歩Misa Kondo
 
Jenkinsとpull requestを利用した、継続的なbundle update.
Jenkinsとpull requestを利用した、継続的なbundle update.Jenkinsとpull requestを利用した、継続的なbundle update.
Jenkinsとpull requestを利用した、継続的なbundle update.Misa Kondo
 
ワンクリックデプロイ見習い勉強会
ワンクリックデプロイ見習い勉強会ワンクリックデプロイ見習い勉強会
ワンクリックデプロイ見習い勉強会Misa Kondo
 
Coffee script初めの一歩
Coffee script初めの一歩Coffee script初めの一歩
Coffee script初めの一歩Misa Kondo
 
Challenge ogx gip 2012.1
Challenge ogx gip 2012.1Challenge ogx gip 2012.1
Challenge ogx gip 2012.1Leotornel
 
Me aiesec and the world
Me aiesec and the worldMe aiesec and the world
Me aiesec and the worldLeotornel
 
Rubyとの出会いから黒歴史を築くまで
Rubyとの出会いから黒歴史を築くまでRubyとの出会いから黒歴史を築くまで
Rubyとの出会いから黒歴史を築くまでMisa Kondo
 
Capistrano introduction
Capistrano introductionCapistrano introduction
Capistrano introductionMisa Kondo
 
Analisis SYBIL dengan PSIKOLOGI
Analisis SYBIL dengan PSIKOLOGIAnalisis SYBIL dengan PSIKOLOGI
Analisis SYBIL dengan PSIKOLOGIYosi Rp
 
PPT Agama Jumlah Rasul dan Nabi
PPT Agama Jumlah Rasul dan NabiPPT Agama Jumlah Rasul dan Nabi
PPT Agama Jumlah Rasul dan NabiLungit Fauzia
 
K.chitra ppaper presentation
K.chitra ppaper presentationK.chitra ppaper presentation
K.chitra ppaper presentationTreesa Jos
 

Andere mochten auch (18)

Introduction git
Introduction gitIntroduction git
Introduction git
 
TDDの神秘
TDDの神秘TDDの神秘
TDDの神秘
 
バージョン管理
バージョン管理バージョン管理
バージョン管理
 
Git introduction2
Git introduction2Git introduction2
Git introduction2
 
Application Release Utilizing MCollective
Application Release  Utilizing MCollectiveApplication Release  Utilizing MCollective
Application Release Utilizing MCollective
 
Challenge ogx gip 2012.1
Challenge ogx gip 2012.1Challenge ogx gip 2012.1
Challenge ogx gip 2012.1
 
Chefのはじめの一歩
Chefのはじめの一歩Chefのはじめの一歩
Chefのはじめの一歩
 
Tired to tdd
Tired to tddTired to tdd
Tired to tdd
 
Jenkinsとpull requestを利用した、継続的なbundle update.
Jenkinsとpull requestを利用した、継続的なbundle update.Jenkinsとpull requestを利用した、継続的なbundle update.
Jenkinsとpull requestを利用した、継続的なbundle update.
 
ワンクリックデプロイ見習い勉強会
ワンクリックデプロイ見習い勉強会ワンクリックデプロイ見習い勉強会
ワンクリックデプロイ見習い勉強会
 
Coffee script初めの一歩
Coffee script初めの一歩Coffee script初めの一歩
Coffee script初めの一歩
 
Challenge ogx gip 2012.1
Challenge ogx gip 2012.1Challenge ogx gip 2012.1
Challenge ogx gip 2012.1
 
Me aiesec and the world
Me aiesec and the worldMe aiesec and the world
Me aiesec and the world
 
Rubyとの出会いから黒歴史を築くまで
Rubyとの出会いから黒歴史を築くまでRubyとの出会いから黒歴史を築くまで
Rubyとの出会いから黒歴史を築くまで
 
Capistrano introduction
Capistrano introductionCapistrano introduction
Capistrano introduction
 
Analisis SYBIL dengan PSIKOLOGI
Analisis SYBIL dengan PSIKOLOGIAnalisis SYBIL dengan PSIKOLOGI
Analisis SYBIL dengan PSIKOLOGI
 
PPT Agama Jumlah Rasul dan Nabi
PPT Agama Jumlah Rasul dan NabiPPT Agama Jumlah Rasul dan Nabi
PPT Agama Jumlah Rasul dan Nabi
 
K.chitra ppaper presentation
K.chitra ppaper presentationK.chitra ppaper presentation
K.chitra ppaper presentation
 

Ähnlich wie PinQAでのMongoDB活用事例

20181031 springfest spring data geode
20181031 springfest spring data geode20181031 springfest spring data geode
20181031 springfest spring data geodeMasaki Yamakawa
 
はてなブックマーク in Scala
はてなブックマーク in Scalaはてなブックマーク in Scala
はてなブックマーク in ScalaLintaro Ina
 
AWS SDK for Smalltalk
AWS SDK for SmalltalkAWS SDK for Smalltalk
AWS SDK for SmalltalkSho Yoshida
 
PostgreSQL 10 新機能 @オープンセミナー香川 2017
PostgreSQL 10 新機能 @オープンセミナー香川 2017PostgreSQL 10 新機能 @オープンセミナー香川 2017
PostgreSQL 10 新機能 @オープンセミナー香川 2017Shigeru Hanada
 
Spring data-rest-and-spring-cloud-contract
Spring data-rest-and-spring-cloud-contractSpring data-rest-and-spring-cloud-contract
Spring data-rest-and-spring-cloud-contractTakeshi Ogawa
 
LODを使ってみよう!
LODを使ってみよう!LODを使ってみよう!
LODを使ってみよう!uedayou
 

Ähnlich wie PinQAでのMongoDB活用事例 (6)

20181031 springfest spring data geode
20181031 springfest spring data geode20181031 springfest spring data geode
20181031 springfest spring data geode
 
はてなブックマーク in Scala
はてなブックマーク in Scalaはてなブックマーク in Scala
はてなブックマーク in Scala
 
AWS SDK for Smalltalk
AWS SDK for SmalltalkAWS SDK for Smalltalk
AWS SDK for Smalltalk
 
PostgreSQL 10 新機能 @オープンセミナー香川 2017
PostgreSQL 10 新機能 @オープンセミナー香川 2017PostgreSQL 10 新機能 @オープンセミナー香川 2017
PostgreSQL 10 新機能 @オープンセミナー香川 2017
 
Spring data-rest-and-spring-cloud-contract
Spring data-rest-and-spring-cloud-contractSpring data-rest-and-spring-cloud-contract
Spring data-rest-and-spring-cloud-contract
 
LODを使ってみよう!
LODを使ってみよう!LODを使ってみよう!
LODを使ってみよう!
 

Kürzlich hochgeladen

IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxAtomu Hidaka
 
20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directoryosamut
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価sugiuralab
 
プレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツールプレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツールsugiuralab
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000Shota Ito
 

Kürzlich hochgeladen (7)

IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
 
20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
 
プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価プレイマットのパターン生成支援ツールの評価
プレイマットのパターン生成支援ツールの評価
 
プレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツールプレイマットのパターン生成支援ツール
プレイマットのパターン生成支援ツール
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000
 

PinQAでのMongoDB活用事例