Skip to content

Latest commit

 

History

History
123 lines (106 loc) · 4.19 KB

04.md

File metadata and controls

123 lines (106 loc) · 4.19 KB

Sample data

Solr comes with some sample data in the example/exampledocs/ folder. You should see a collection of files like this:

books.csv		ipod_other.xml		money.xml		post.jar		test_utf8.sh
books.json		ipod_video.xml		monitor.xml		post.sh			utf8-example.xml
gb18030-example.xml	manufacturers.xml	monitor2.xml		sd500.xml		vidcard.xml
hd.xml			mem.xml			mp500.xml		solr.xml

Using the post.jar java file, we'll add these all to the Solr index.

If it's not running, restart Solr (with the command from the last lesson) and issue the following command from the exampledocs/ folder:

java -jar post.jar *.xml

You should output like this on the command line:

SimplePostTool version 1.5
Posting files to base url http://localhost:8983/solr/update using content-type application/xml..
POSTing file gb18030-example.xml
POSTing file hd.xml
POSTing file ipod_other.xml
POSTing file ipod_video.xml
POSTing file manufacturers.xml
POSTing file mem.xml
POSTing file money.xml
POSTing file monitor.xml
POSTing file monitor2.xml
POSTing file mp500.xml
POSTing file sd500.xml
POSTing file solr.xml
POSTing file utf8-example.xml
POSTing file vidcard.xml
14 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/update..
Time spent: 0:00:00.582

You should now have data your installation of Solr. Follow this URL for a blank query to test that some data is returned. You should see an XML document that looks like this...

(Note that XML is the default output. If you're more comfortable working in another format, you can specify a format writer with the wt parameter. E.g. http://localhost:8983/solr/collection1/select?q=%3A&wt=json&indent=true.)

<response>
  <lst name="responseHeader">
    <int name="status">0</int>
    <int name="QTime">0</int>
    <lst name="params">
      <str name="q">*:*</str>
    </lst>
  </lst>
  <result name="response" numFound="32" start="0">
    <doc>
      <str name="id">GB18030TEST</str>
      <str name="name">Test with some GB18030 encoded characters</str>
      <arr name="features">
      <str>No accents here</str>
      <str>这是一个功能</str>
      <str>This is a feature (translated)</str>
      <str>这份文件是很有光泽</str>
      <str>This document is very shiny (translated)</str>
      </arr>
      <float name="price">0.0</float>
      <str name="price_c">0,USD</str>
      <bool name="inStock">true</bool>
      <long name="_version_">1471713166838726656</long>
    </doc>
    <doc>
      <str name="id">SP2514N</str>
      <str name="name">
      Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133
      </str>
      <str name="manu">Samsung Electronics Co. Ltd.</str>
      <str name="manu_id_s">samsung</str>
      <arr name="cat">
      <str>electronics</str>
      <str>hard drive</str>
      </arr>
      <arr name="features">
      <str>7200RPM, 8MB cache, IDE Ultra ATA-133</str>
      <str>
      NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor
      </str>
      </arr>
      <float name="price">92.0</float>
      <str name="price_c">92,USD</str>
      <int name="popularity">6</int>
      <bool name="inStock">true</bool>
      <date name="manufacturedate_dt">2006-02-13T15:26:37Z</date>
      <str name="store">35.0752,-97.032</str>
      <long name="_version_">1471713166890106880</long>
    </doc>
...
  </result>
</response>

Let's take a few minutes to unpack this:

The whole response is being returned within a response element. Within this, there are two elements, a responseHeader and the result. The responseHeader is returning your query back to you:

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">0</int>
  <lst name="params">
    <str name="q">*:*</str>
  </lst>
</lst>

The params element is most notable for us - it repeats the content of your search query.

The result element contains all of the documents matching our search, denoted with the doc tag. Solr calls it's records "documents", so remember that term.

Next let's take a look at the administrative interface.

Next or Back or Home