Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apache Solr v4 Spatial Search

Apache Solr v4 Spatial Search

Keisuke Makino

July 21, 2013
Tweet

More Decks by Keisuke Makino

Other Decks in Programming

Transcript

  1. Solr v3 => v4 v3 Ͱ΋ۭؒݕࡧ͸αϙʔτ v4.3.1 Ͱ͸ v3 ܗࣜ΋αϙʔτ

    v4.3.1 ࣌఺Ͱͷ example ͷ schema.xml ͸·ͩ v3 ͷۭؒݕࡧํࣜ 13೥7݄21೔೔༵೔
  2. Put jts.jar in solr.war jts.jar Λμ΢ϯϩʔυ http://sourceforge.net/projects/jts-topo- suite/ solr.war Λղౚ

    WEB-INF/lib ഑Լʹ jts.jar Λ഑ஔ solr.war ʹ࠶౓ΞʔΧΠϒ 13೥7݄21೔೔༵೔
  3. MEMO JTS The JTS Topology Suite is an API for

    modelling and manipulating 2- dimensional linear geometry. WKT (Well Known Text) Well-known text (WKT) is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference systems. 13೥7݄21೔೔༵೔
  4. Example: Indexing (Point) ֳۚࣉ <field name=”store”>135.729 35.039</field> ֳۜࣉ <field name=”store”>135.798

    35.026</field> ژ౎Ӻ <field name=”store”>135.757 34.986</field> 13೥7݄21೔೔༵೔
  5. Example: Indexing (Python) import pysolr def main(): solr = pysolr.Solr('http://localhost:8983/solr/',

    timeout=10) solr.add([ { "id": "1", "name": u"ֳۚࣉ", "store": "135.729 35.039" }, { "id": "2", "name": u"ֳۜࣉ", "store": "135.798 35.026" }, { "id": "3", "name": u"ژ౎Ӻ", "store": "135.757 34.986" } ]) solr.optimize() if __name__ == '__main__': main() 13೥7݄21೔೔༵೔
  6. Example: Searching docs: [ { id: "2", store: "135.798 35.026",

    name: "ֳۜࣉ", score: 0.052228004 }, { id: "1", store: "135.729 35.039", name: "ֳۚࣉ", score: 0.057749357 } ] score ͕த৺఺͔Βͷ ڑ཭(distance) ୯Ґ͸ degrees 13೥7݄21೔೔༵೔
  7. More Information Solr Wiki: Spatial Search http://wiki.apache.org/solr/SpatialSearch Solr Wiki: Lucene

    / Solr 4 Spatial http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 Github: spatial4j https://github.com/spatial4j/spatial4j 13೥7݄21೔೔༵೔