GitHub - PebbleRoad/mithril-solr: An Front-end Interface to Solr

1 min read Original article ↗
 <script>
   /**
    * Fields
    * @type {Object}
    */

   var fields = {
       title   : 'alternate_title',
       summary : 'abstract',
       url     : 'presentation_url'
   };
   
   /**
    * Facets
    * @type {Array}
    */
   
   var facetFields = [
     {
       name: 'region',
       displayName: 'Region',
       type: 'string'
     },
     {
       name: 'function',
       displayName: 'Function',
       type: 'string'
     },
     {
       name: 'localtype',
       displayName: 'Region',
       type: 'string'
     },
     {
       name: 'toDate',
       displayName: 'Date',
       type: 'date'
     }
   ]

   /**
    * Your App
    * @type {Object}
    */
   var app = {
       controller: function(){
   
           this.endPoint = 'https://data.esrc.unimelb.edu.au/solr/FACP/select';
   
           this.facetFields = facetFields;
   
           this.fields = fields;
   
       },
       view: function(ctrl){
           return [
               m.component(SolrWidget, {                            
                   endPoint: ctrl.endPoint,
                   facetFields: ctrl.facetFields,
                   fields: ctrl.fields
               })
           ]
       }
   }
   
   /* Mount */
   
   m.route.mode = 'hash';
   m.route(document.getElementById('Search'), '/search', {
       '/search': app
   });
 </script>