Solr worked example with National Trees, from "Ground up" :)

This is minimum to get Solr 9.8 started:

 <schema name="national_trees_MAY_2025" version="1.6">
  <uniqueKey>ogr_fid</uniqueKey>

<!-- Reserved/Required -->
<field name="_version_" type="long" indexed="true" stored="true"/>

<!-- Bools -->
  <fieldType name="boolean" class="solr.BoolField"/>
  <fieldType name="booleans" class="solr.BoolField" multiValued="true"/>

<!-- Numerics -->
<fieldType name="pint" class="solr.IntPointField"/>
<fieldType name="pints" class="solr.IntPointField" multiValued="true"/>
<fieldType name="plong" class="solr.LongPointField"/>
<fieldType name="plongs" class="solr.LongPointField" multiValued="true"/>
<fieldType name="pfloat" class="solr.FloatPointField"/>
<fieldType name="pfloats" class="solr.FloatPointField" multiValued="true"/>
<fieldType name="pdouble" class="solr.DoublePointField"/>
<fieldType name="pdoubles" class="solr.DoublePointField" multiValued="true"/>

<!-- Dates -->
<fieldType name="pdate" class="solr.DatePointField"/>
<fieldType name="pdates" class="solr.DatePointField" multiValued="true"/>

<!-- Strings -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" docValues="true"/>

<!-- Custom -->

<fieldType name="long" class="solr.LongPointField"/>

<!-- LatLonPointSpatialField is the ideal field type for the most common use-cases for lat-lon point data. RPT offers some more features for more advanced/custom use cases and options like polygons and heatmaps. -->
<!-- <fieldType name="location_rpt" class="solr.LatLonPointSpatialField"/> -->


<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

<!-- https://solr.apache.org/guide/solr/latest/query-guide/spatial-search.html  look at end of page -->
<!-- required downloading https://mvnrepository.com/artifact/org.locationtech.jts/jts-core/1.17.1 -->
<!-- and placing in SOLR_INSTALL/server/solr-webapp/webapp/WEB-INF/lib/ -->

<fieldType name="location_rpt"   class="solr.SpatialRecursivePrefixTreeFieldType"
               spatialContextFactory="JTS"
               autoIndex="true"
               validationRule="repairBuffer0"
               distErrPct="0.025"
               maxDistErr="0.001"
               distanceUnits="kilometers" />


<!-- Field Names -->



     <field name="ogr_fid" type="string" indexed="true" stored="true" required="true"/>
<!-- "ogr_geometry_wkt" I think this one might be good for converting to geoJson on output-->
     <field name="ogr_geometry_wkt" type="string" indexed="false" stored="true" docValues="true"/>
<!-- <field name="ogr_geometry_wkt" type="text_general" indexed="false" stored="true" docValues="true"/> -->
<!-- <field name="ogr_geometry_wkt" type="text_general" indexed="false" stored="true"/> -->
     <field name="tow_id" type="string" indexed="true" stored="true"/>
     <field name="woodland_t" type="text_general" indexed="true" stored="true"/>

<!-- "geo" This one is stored=false because we don't want in output. But is available for spatial search-->
     <field name="geo" type="location_rpt" indexed="true" stored="false"/>
  
     <field name="meanht" type="pfloat" indexed="true" stored="true"/>
     <field name="maxht" type="pfloat" indexed="true" stored="true"/>
     <field name="tow_area_m" type="pdouble" indexed="true" stored="true"/>
  <!-- Add any others -->


</schema>

Notes: See comments within



solrconfig.xml

  After <luceneMatchVersion>9.11</luceneMatchVersion> Add
    <schemaFactory class="ClassicIndexSchemaFactory"/>  

and in 

<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:false}"

from update.autoCreateFields:true

Comments

Popular posts from this blog

git journey

Django Journey

github start project