Skip to content

Instantly share code, notes, and snippets.

@basdenooijer
Created April 15, 2011 13:44
Show Gist options
  • Save basdenooijer/921717 to your computer and use it in GitHub Desktop.
Save basdenooijer/921717 to your computer and use it in GitHub Desktop.
Solarium configuration mode
[solr]
; client connection settings
client.host = "192.168.1.2"
client.port = 8983
client.path = /solr/
client.core = geonames
; a complex select query based on configuration
complexselect.rows = 15
complexselect.start = 100
complexselect.fields = id,name,population,countrycode
complexselect.sort.name = asc
complexselect.sort.population = desc
complexselect.filterquery.fq1.tag = populationLimit
complexselect.filterquery.fq1.query = "population:[1 TO 1000000]"
complexselect.facet.countries.type = field
complexselect.facet.countries.field = countrycode
complexselect.facet.countries.limit = 10
complexselect.facet.bigcities.type = query
complexselect.facet.bigcities.query = "population:[1000000 TO *]"
complexselect.facet.bigcities.exclude = populationLimit
; an update query:
; IMPORTANT this is just an example to show all commands, not ready to use!
updatequery.command.key1.type = delete
updatequery.command.key1.query = "population:[* TO 1000]"
updatequery.command.key1.id[] = 1
updatequery.command.key1.id[] = 2
updatequery.command.key2.type = commit
updatequery.command.key2.waitflush = true
updatequery.command.key2.waitsearcher = false
updatequery.command.key2.expungedeletes = true
updatequery.command.key3.type = optimize
updatequery.command.key3.waitflush = true
updatequery.command.key3.waitsearcher = false
updatequery.command.key3.maxsegments = 5
updatequery.command.key4.type = rollback
<?php
// load config and create Solarium client instance
// (if you don't want to use Zend_Config you can use a plain array instead of the ini file)
$config = new Zend_Config_Ini('Config.ini');
$solr = new Solarium_Client($config->solr->client);
// build select query based on config
$query = new Solarium_Query_Select($config->solr->complexselect);
$result = $solr->select($query);
// build update query based on query
$query = new Solarium_Query_Update($config->solr->updatequery);
$result = $solr->update($query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment