2017 © Pedro Peláez
 

library laravel-solarium

Laravel Framework package for using Solarium

image

jitenderrawal/laravel-solarium

Laravel Framework package for using Solarium

  • Monday, December 5, 2016
  • by jitenderrawal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 7 Versions
  • 3 % Grown

The README.md

Laravel-Solarium

Laravel Framework package for using Solarium, (*1)

Features

  • Observes your app's models for inserts, updates and deletes and stores data in a Solr index
  • Supports multiple Solr cores, so you can have different models saving to different cores, or the same model to multiple cores. Useful if you have multiple search facilities in your app, e.g. product search function and general site search.
  • Includes route (configurable URI) and controller for querying a site search core.
  • Includes sample site search results view, which you can use, if you want, but you'll most likely want to just use the partial views...
  • Partial view for site search form that you could include in your layout header
  • Partial view for the site search results that you can include from your custom search results view

Installation

Setting up Solr

Download the latest version of solr : http://lucene.apache.org/solr/, (*2)

Unpackage : tar xvzf solr-4.*.*.tgz, (*3)

Copy the example directory and rename it in this case : site-search, (*4)

Then rename the collection1 directory to what you would like to call your index., (*5)

In this case the index will be called search., (*6)

If you require more than one index, then copy and rename the site-search folder., (*7)

Then update the solr.xml file to tell the solr server how many indexes you have and their names., (*8)

for example :, (*9)



<solr persistent="false">

  <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
    <core name="search" instanceDir="search" />
    <!-- only include this is you have created the second index folder -->
    <core name="index2" instanceDir="index2" />
  </cores>

  <shardHandlerFactory name="shardHandlerFactory"
    class="HttpShardHandlerFactory">
    <int name="socketTimeout">${socketTimeout:0}</int>
    <int name="connTimeout">${connTimeout:0}</int>
  </shardHandlerFactory>

</solr>

Now for each created index folder you need to update the schema.xml and solrconfig.xml files in the index config folder., (*10)

example schema.xml file :, (*11)


<schema name="search" version="1.1">
  <types>
    <fieldType name="string"  class="solr.StrField"  sortMissingLast="true" omitNorms="true" />
    <fieldType name="long"    class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
  </types>

  <fields>
    <field name="id"              type="string"  indexed="true"  stored="true"  multiValued="false" required="true"/>
    <field name="model_id"        type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="model_name"      type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="title"           type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="content"         type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="search_content"  type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="published_date"  type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="archive_date"    type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="status"          type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="url"             type="string"  indexed="true"  stored="true"  multiValued="false" />
    <field name="_version_"       type="long"    indexed="true"  stored="true"/>
  </fields>

  
  <uniqueKey>id</uniqueKey>

  
  <defaultSearchField>title</defaultSearchField>

  
  <solrQueryParser defaultOperator="OR"/>
</schema>

example solrconfig.xml :, (*12)

This is best created by copying the matching folder in the provided example directory., (*13)





<config>
  <luceneMatchVersion>4.5</luceneMatchVersion>
  
  <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>

  <dataDir>${solr.search.data.dir:}</dataDir>

  
  <schemaFactory class="ClassicIndexSchemaFactory"/>

  <updateHandler class="solr.DirectUpdateHandler2">
    <updateLog>
      <str name="dir">${solr.search.data.dir:}</str>
    </updateLog>
  </updateHandler>

  
  <requestHandler name="/get" class="solr.RealTimeGetHandler">
    <lst name="defaults">
      <str name="omitHeader">true</str>
    </lst>
  </requestHandler>

  <requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />

  <requestDispatcher handleSelect="true" >
    <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" formdataUploadLimitInKB="2048" />
  </requestDispatcher>

  <requestHandler name="standard" class="solr.StandardRequestHandler" default="true" />
  <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
  <requestHandler name="/update" class="solr.UpdateRequestHandler"  />
  <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />

  <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
    <lst name="invariants">
      <str name="q">solrpingquery</str>
    </lst>
    <lst name="defaults">
      <str name="echoParams">all</str>
    </lst>
  </requestHandler>

  
  <admin>
    <defaultQuery>solr</defaultQuery>
  </admin>

</config>

You will also need to update the core.properties file in the index folder :, (*14)

The contents are very simple e.g. :, (*15)

name=search, (*16)

Then run sudo java -jar start.jar in the index directory., (*17)

This will start the solr server, which if configured correctly should be viewable at :, (*18)

http://localhost:8983/solr/#/search, (*19)

Getting the laravel-solarium package

Add the following to your composer.json file if using composer :, (*20)

"require": {
  "fbf/laravel-solarium": "dev-master"
},

and then do a composer update, (*21)

Add the ServiceProvider in app/config/app.php, (*22)

'Fbf\LaravelSolarium\LaravelSolariumServiceProvider', (*23)

Publish the config file:, (*24)

php artisan config:publish fbf/laravel-solarium, (*25)

Edit the config file., (*26)

The Versions

05/12 2016

dev-master

9999999-dev

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer

02/04 2015

v0.1.5

0.1.5.0

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer

10/09 2014

v0.1.4

0.1.4.0

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer

01/09 2014

v0.1.2

0.1.2.0

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer

01/09 2014

v0.1.3

0.1.3.0

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer

01/09 2014

v0.1.1

0.1.1.0

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer

09/01 2014

v0.1.0

0.1.0.0

Laravel Framework package for using Solarium

  Sources   Download

MIT

The Requires

 

by Zenek Palmer