Archive June 2011:
If you simply want to delete documents from your Solr index by using the web interface, here's a code snippet that lets you do so:
This lets you delete documents where the id field matches 298253.
If you want to delete items that matches more than one field, just add another query:
If you want to delete all items in the index, just use this query:
If you get the NullReferenceException error when dealing with web services, it might have to do with AutoEventWireUp being set to false. If you get an error pointing at something like
foreach (ServiceDescription description in serviceDescriptions), it might also have to do with AutoEventWireUp set to false.
For instance, if you set AutoEventWireUp to false globally, in Web.Config, your web services will fail.
There's a fix for this though, although it's a bit of a different one.
You just have to locate the DefaultWsdlHelpGenerator.aspx file in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG (or similar) and add this line to the top:
<%@ Page AutoEventWireup="true" %>
If you get the Java Heap Space OutOfMemoryError in Apache Tomcat, then there's quite an easy fix *.
In Apache Tomcat, you can customize the memory settings, thus allowing more memory to Java clients like Solr.
Just fire up "Configure Tomcat", click on the "Java" tab and allocate enough memory in the "Initial memory pool" and "Maximum memory pool" fields:
What memory size should you allocate here? Well, it depends. The default initial memory pool is 64 MB. If you've got a pretty large search index with many searches, you'll surelly need more memory allocated.
In a project here, where we've got approximately 20 Million indexed items being searched, 256 MB weren't enough as initial memory pool. 512 MB so far seems to work it out. I guess you just have to try some different values out, and monitor Tomcat's performance while fine-tuning.
* Also take a look at my other blog post on Java heap space issues and 32 / 64 bit versions of Apache Tomcat and Java.
If you encounter problems with Solr indexing and inconsistencies in the actual indexing - you might have a problem with the Solr unique key field.
If you index items that may have the same id, and this id is used as the unique key in Solr - then you have a problem. Items with the same id's will simply not be tolerated in the Solr index, thus the latter item overwrites the former when indexing. Of course, this is a default and correct behaviour from Solr.
However - this is easy to solve. You just have to use the UUID (Universal Unique Identifier) field type in Solr.
In schema.config in your Solr conf folder (normally C:/solr/conf or similar), add the UUID type, like this:
<fieldType name="uuid" class="solr.UUIDField" indexed="true" />
Then, add a field of this type (still in schema.config):
<field name="uid" type="uuid" indexed="true" stored="true"
Finally, make sure to point out this field as the unique key, in schema.config:
All done! Now all your indexed items will have a unique ID.
Here's more documentation on Solr and the UniqueKey field.