views:

43

answers:

1

I am using Solr-php-client to communicate with solr via php.

I search solr by using this php-client and amongst other information I get from Solr, the total results are returned to a variable in php:

$results = $solr->search($querystring, $start_offset, $limit, $solr_params);
$num_total = (int) $results->response->numFound;

My problem is that when I add a document to Solr WITHOUT committing it, the $num_total is increased anyways. So this means either of two things, or both:

1- Solr autoCommit doesn't work
2- The solr-php-client returnes nr of documents instead of nr of committed documents.

I might have missed something simple here, so I would appreciate any help.

Anyways, here is what I have done with the solrconfig.xml:

  <autoCommit> 
    <maxDocs>3</maxDocs>
    <maxTime>60000</maxTime> 
  </autoCommit>

The number "3" is only for testing purposes, but didn't work as mentioned above.

Is there any other settings I should think of besides this above when using autoCommit?

I have restarted jetty (my container) and solr after changing the solrconfig.xml file also.

If you need more input just let me know...

Thanks

+1  A: 

The php solr client isn't doing anything special here, the numFound is exactly what Solr itself is returning. Which should be based on committed documents at the time of the query.

I'm slightly confused by your question though. Is your complaint that you're seeing documents being autocommitted before you expect them to be? If so, you should be testing the opposite way that you are - increasing the number of maxDocs in the autoCommit block. I'm not sure what guarantees solr itself makes for how close to that maxDocs it will allow before triggering a commit. Typical settings are 1,000 or 10,000 depending on your indexing characteristics. And then time is usually used as an upper bound as to how long you're willing to wait for a document to show up in the index. You're trying to reach a balance between efficiency and latency.

In any case, the only way you'll get to the bottom of what is happening is by looking at the log for Solr - it will have entries for the add, the query, and the commit and you can see how close or far apart they are from one another, or if there is an explicit commit that you don't know about in the code.

If you could update your question with a portion of that log it'd be helpful in helping you diagnose.

donovan Jimenez