lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Schmidt <...@535consulting.com>
Subject Re: Which version of Solr?
Date Mon, 14 Feb 2011 04:15:17 GMT
Hello again:

Back to the javabin iissue:

On Feb 12, 2011, at 6:07 PM, Lance Norskog wrote:

> --- But I'm unable to get SolrJ to work due to the 'javabin' version
> mismatch. I'm using the 1.4.1 version of SolrJ, but I always get an
> HTTP response code of 200, but the return entity is simply a null
> byte, which does not match the version number of 1 defined in Solr
> common.  ---
> 
> I've never seen this problem. At this point you are better off
> starting with 3.x instead of chasing this problem down.

I'm now using the latest branch_3x built Solr and SolrJ.  Other places I've seen the message:

Caused by: java.lang.RuntimeException: Invalid version (expected 2, but 0) or the data in
not in 'javabin' format at org.apache.solr.common.util.JavaBinCodec.unmarshal(JavaBinCodec.java:99)
at org.apache.solr.client.solrj.impl.BinaryResponseParser.processResponse(BinaryResponseParser.java:41)


One was told to make sure the version of Solr and SolrJ are compatible, and that the schema
is valid. Unlike 1.4, I see 3.1 actually outputs the expected and received version numbers,
which is helpful. You can see the invalid version of 0 is indicated which is the zero byte
I receive in response.

I have Solr running within Tomcat by following the wiki.  I have the conf/Catalina/localhost/solr.xml
file set as:

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/usr/local/ingenuity/isec/solr/apache-solr-3.1-SNAPSHOT.war" debug="0"
crossContext="true">
  <Environment name="solr/home" type="java.lang.String"
      value="/Users/jas/535Consulting/Clients/Ingenuity/ProfServices/svn/trunk/ing/isec/src/main/solr/multicore"
      override="true"/>
</Context>

 With that, I'm able to use my browser to index some content (DIH, curl etc.) and issue queries,
so it seems Solr is running okay in tomcat (apache-tomcat-6.0.30). To index some Products,
I have this simple method:

	@Override
	public void addProducts(final Collection<Product> products, final String indexName)
{
		
		log.info(String.format("addProducts - indexing %d products to Solr core: %s",
				products.size(), indexName));
		
		Assert.notNull(indexName);
		
		final Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
		for (Product product : products) {
		
			final SolrInputDocument doc = createDocumentForProduct(product);
			docs.add(doc);
			log.info("addProduct: document to index: " + doc);
		}
		
		final SolrServer solrServer = getSolrServer(indexName);
		try {
			solrServer.add(docs);
			solrServer.commit(commitWaitFlush, commitWaitSearcher);
		} catch (Exception ex) {
			final String msg = String.format("Unable to add and commit %d documents to core: %s",
					products.size(), indexName);
			log.error(msg);
			throw new ServiceException(msg, ex);
		}		
	}

And I have:

	protected SolrServer getSolrServer(final String indexName) {

		final String url = solrServerBaseUrl + indexName;
		log.info("getSolrServer - construct server for url: " + url);
		try {
			final CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(solrServerBaseUrl +
indexName);
			//solrServer.setParser(new BinaryResponseParser());
			//solrServer.setParser(new XMLResponseParser());
			solrServer.setRequestWriter(new BinaryRequestWriter());
			return solrServer;
		} catch (Exception ex) {
			final String msg = String.format("Unable to create Solr server for url: %s", url);
			log.error(msg);
			throw new ServiceException(msg, ex);			
		}		
	}

Note that this is code for prototyping. :)

As you can see, in getSolrServer() I'm trying various settings.  http://wiki.apache.org/solr/Solrj
is tagged Solr 1.4, but I'm assuming it's at least very similar in 3.1. For the core in question,
solrconfig.xml does have:

  <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
  <requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" />

I can see in the Solr log:

Feb 13, 2011 3:35:14 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig
INFO: created /update/javabin: solr.BinaryUpdateRequestHandler

Running this through the burp proxy to try to see what's going on, I can see my application
making the following request to Solr via SolrJ:

------------------------------------------
POST /solr/partner-tmo/update/javabin?wt=javabin&version=2 HTTP/1.1
User-Agent: Solr[org.apache.solr.client.solrj.impl.CommonsHttpSolrServer] 1.0
Host: localhost:8090
Content-Type: application/octet-stream
Content-Length: 543

Äà&paramsÀà'delById
Mime
View raw message