Share
Embed
Transcript
19 slides
-
Solr v3 => v4 v3 Ͱۭؒݕࡧαϙʔτ v4.3.1 Ͱ v3 ܗࣜαϙʔτ
v4.3.1 ࣌Ͱͷ example ͷ schema.xml ·ͩ v3 ͷۭؒݕࡧํࣜ 137݄21༵ -
Solr v3 => v4 Solr v4 Ͱݕࡧ/ઃఆํ๏͕มߋ fieldType ͷՃ (location_rpt)
geodist() ͷ༻Λඇਪ 137݄21༵ -
Dependency library ۭؒݕࡧϩδοΫ OSS ͷ spatial4j solr.war ʹೖͬͯΔ ϙϦΰϯΛݕࡧ͍ͨ͠߹ jts.jar
͕ඞཁ solr.war ʹೖͬͯͳ͍ 137݄21༵ -
Put jts.jar in solr.war jts.jar Λμϯϩʔυ http://sourceforge.net/projects/jts-topo- suite/ solr.war Λղౚ
WEB-INF/lib Լʹ jts.jar Λஔ solr.war ʹ࠶ΞʔΧΠϒ 137݄21༵ -
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. 137݄21༵ -
Example: schema.xml <types> .... <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" geo="true" distErrPct="0.025" maxDistErr="0.000009"
units="degrees" /> .... </types> 137݄21༵ -
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> 137݄21༵ -
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() 137݄21༵ -
Example: Searching ژӺΛத৺, पล10km, Ωʔϫʔυ: “ࣉ” http://localhost:8983/solr/collection1/select? q={!geofilt score=distance sfield=store
pt=34.986,2C135.757 d=10} &fq=name:ࣉ&sort=score asc&fl=*,score 137݄21༵ -
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 137݄21༵ -
Units, Conversion ڑͷ୯ҐมSolr WikiΛࢀߟʹ http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4#Units. 2C_Conversion Degrees to kilometers: degrees
* 111.1951 Degrees to miles: degrees * 69.09341 137݄21༵ -
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 137݄21༵