Setting up a Solr Index

February 17, 2009 – 5:51 pm

Setting up a solr index isn’t that hard, but I found the documentation to be somewhat hard to find. It only took me a few hours from start to finish to go from download to indexing my documents, but I think it could have happened a lot faster if I had some of the below information. I’m assuming you’ve already downloaded solr and you’re now looking at a directory with a bunch of files in it.

  • Make a copy of the example directory found in the solr directory. To make obvious, I just named it after the site I’m working on.
  • You’ll want to edit the solr/conf/schema.xml file found in there. It’s actually a really good sample file to get started with, so you’ll learn a whole bunch by starting there. Information on the solr schema. You’ll need to modify the configuration file for solr to function correctly with your schema.
  • If you’re using a PHP and curl, and you get the error “missing content stream”, you need to make sure you set your curl header

    curl_setopt($c, CURLOPT_HTTPHEADER, array(”Content-Type: text/xml”));

  • At one point, I received the error “Unexpected EOF in prolog” – this was because I originally had a “\n” at the end of my header (see previous note). Removing it solved my problem.
  • Here’s a good solr starting point that covers the schema and field types.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  1. One Response to “Setting up a Solr Index”

  2. Hi

    I had a similar problem although I was passing the text/xml header with curl.

    My problem was that I was also sending a ‘Content-Length’ header with the length of the xml passed. This also caused a ‘400 missing content stream’ error.

    Andrew

    By Andrew McCombe on May 26, 2009

Post a Comment