Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
国交省のデータをSolrで検索
Search
ryo0301
July 29, 2013
Technology
1.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
国交省のデータをSolrで検索
SHAPE > PostGIS > Solr > Google Map
ryo0301
July 29, 2013
More Decks by ryo0301
See All by ryo0301
Blockchain x Slack botでピアボーナス
ryo0301
0
290
Quorum on AWS
ryo0301
0
650
Other Decks in Technology
See All in Technology
自主式軟體工廠
philipz
0
250
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
0
250
go-sqletch
moznion
0
130
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
270
自作バイナリを動かす「入口」8選
puhitaku
1
1.2k
Google Cloud Next Tokyo 26登壇時のスクリプト
recruitengineers
PRO
0
220
OpenSharing について熱く語る〜AI アセットの共有について〜
kameitomohiro
0
240
FOSS4Gを活用した自治体業務DXの試み
470715
0
140
自律型 AI をセキュアに実装!Gemini と MIG で作る動的コード実行環境
recruitengineers
PRO
1
240
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
320
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
370
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
540
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
260
Discover your Explorer Soul
emna__ayadi
2
1.3k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
400
Tell your own story through comics
letsgokoyo
1
1.1k
My Coaching Mixtape
mlcsv
0
340
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
GraphQLとの向き合い方2022年版
quramy
50
15k
Building an army of robots
kneath
307
47k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
WCS-LA-2024
lcolladotor
0
860
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
630
Transcript
国土交通省のデータをSolrで検索 株 式 会 社 ネ ク ス ト 秀
野 亮 @ r y o 0 3 0 1
自己紹介 秀野 亮 株式会社ネクスト @ryo0301 不動産・住宅情報サイト HOME'S http://www.homes.co.jp/ 最近の仕事 Solr
-> AWS -> DQ10
発表の概要 Lucene/Solr4の新しい(地理)空間検索 http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 上記の機能を使ったデモとその説明 国交省のデータ -> PostGIS -> Solr
デモ:想定した機能 地図上の小学校から、その学区内の物件を検索 小学校をクリック 学区を表示 学区内の物件を表示 地図上の指定した範囲の物件を検索 おまけ 内部的には同じ機能
デモ:環境 バージョン(5月時点の最新版) Solr4.3.0 PostGIS2.0.3 データ 東京都のデータ POLYGON:学区 POINT:小学校、公園、公共施設、バス停 ※物件代わりに利用
デモ:やります 少々お待ちください
デモ:実演中…
事前知識 説明の前に軽く事前知識を・・・
事前知識:ジオメトリデータ 点:駅/物件など POINT MULTIPOINT 線:路線など LINESTRING MULTILINESTRING 面:市区町村/学区など POLYGON MULTIPOLYGON
事前知識:WKB/WKT形式 WKB Well Known Binary 0101000000000000000000F03F000000000000F03F PostgreSQL(PostGIS)にはWKB形式で格納 WKT Well Known
Text MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((5 5,7 5,7 7,5 7, 5 5))) Solrへのインポート、検索クエリはWKT形式で行う
事前知識:Intersects Intersects 交差するデータを検索する関数
環境:データの流れ &$ TIQQHTRM 1PTU(*4 HFPNLNM LNMT 4 4PMS %*) ࠃަল
環境:SHAPE -> PostGIS &$ TIQQHTRM 1PTU(*4 HFPNLNM LNMT 4 4PMS
%*) ࠃަল
環境:SHAPE -> PostGIS 国土交通省のデータを使って、緯度経度から市区町村までを取り出す http://qiita.com/masuidrive/items/21a282c7bf54fd6a4985
環境:PostGIS -> Solr &$ TIQQHTRM 1PTU(*4 HFPNLNM LNMT 4 4PMS
%*) ࠃަল
環境:PostGIS -> Solr PostGIS -> DIH DIHでDBから一括インポート select *, ST_AsText(geom)
from school_district; ST_AsText関数でWKB→WKT変換 DIH -> Solr SpatialRecursivePrefixTreeFieldType geohashで階層的にインデックスを保持 WKT形式でインポート
環境:PostGIS -> Solr schema.xml <fieldType name="location" class="solr.SpatialRecursivePrefixTreeFieldType" spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory" distErrPct="0.025" maxDistErr="0.000009"
units="degrees"/> <field name="geo" type="location" indexed="true" stored="true" multiValued="true"/>
環境:PostGIS -> S3 &$ TIQQHTRM 1PTU(*4 HFPNLNM LNMT 4 4PMS
%*) ࠃަল
環境:PostGIS -> S3 geom2kml select ST_AsKml(geom) from school_district; ST_AsKml関数でKML形式に変換 ERBでKMLファイルを生成
MULTIPOLYGONデータ(学区)が対象 kml2s3 KMLファイルをAmazon S3にアップロード
環境:PostGIS -> S3 ST_AsKml関数の出力結果(MULTIPOLYGON) <MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates >139.763459000000012,35.6... 139.763459000000012,35.663246999999998</coordinates></ LinearRing></outerBoundaryIs></Polygon></MultiGeometry>
環境:Solr/S3 -> Google Map &$ TIQQHTRM 1PTU(*4 HFPNLNM LNMT 4
4PMS %*) ࠃަল
環境:Solr/S3 -> Google Map KmlLayer 学区の範囲をGoogleMap上に表示 S3上のKMLファイルのURLを指定するだけ Solrでの検索 小学校検索 (geo:[10,20
TO 30,40]) 小学校→学区検索 (POINT→MULTIPOLYGON) 学区→物件検索 (MULTIPOLYGON→POINT) 指定範囲検索 (POLYGON→POINT)
実際のクエリ 小学校→学区検索 (POINT→MULTIPOLYGON) fq=geo:"Intersects(POINT(139.7343+35.6364))" 学区→物件検索 (MULTIPOLYGON→POINT) fq=geo:"Intersects(MULTIPOLYGON(((139.737202 35.640305,139.737358 35.640414,...305))))" ※geoフィールドに対して検索
注意点:必要なライブラリ Spatial4J https://github.com/spatial4j/spatial4j geospatial JTS http://sourceforge.net/projects/jts-topo-suite/ spatial polygon support
注意点:必要なライブラリ Solr adapters Lucene spatial Spatial4J JTS
注意点:インデクシング遅い MULTIPOLYGONのインデクシングが遅い 驚きの遅さ PostGISに間引きしてくれる関数があったような…
EOP ありがとうございました。
蛇足 ネクストでは、 ヌルスタックエンジニアを 募集しています!