Starting, stopping, indexing, clearing indexes and dealing with search results in Solr

To start solr with the default Jetty server, go to the solr installation directory/example

java -jar start.jar

To start and run solr in the background

java -jar start.jar &

To stop solr in windows, press Ctrl-C.

To stop solr in nix os, press Ctrl-C if it running on the foreground. If it’s running in the background, find the pid by

ps -ef | grep "start.jar"

Assume the pid for the solr is 125647, type the following to stop solr

kill -9 125647

Indexing the sample data that came with the solr download, go to example/exampledocs/

java -jar post.jar solr.xml monitor.xml

To index all the sample data.

java -jar post.jar *.xml

To delete a document, for example the document with id SP2514N

java -Ddata=args -Dcommit=no -jar post.jar "<delete><id>SP2514N</id></delete>"
java -jar post.jar

To delete a document by query

java -Ddata=args -jar post.jar "<delete><query>name:DDR</query></delete>"

To delete all documents from the index by command line

curl http://localhost:8983/solr/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'  
curl http://localhost:8983/solr/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'

To delete all documents from the index by http call from a browser

http://localhost:8983/solr/update?stream.body=<delete><query>*:*</query></delete>
http://localhost:8983/solr/update?stream.body=<commit/>

Example of dealing solr search results by php

<?php
$code = file_get_contents('http://localhost:8983/solr/select/?q=sku%3A0123364356&wt=php');
eval("\$result = " . $code . ";");
print_r($result);
?>

Search within Codexpedia

Custom Search

Search the entire web

Custom Search