views:

437

answers:

3

I have a classifieds website... I have Solr doing the searching of the classifieds, and then return ID:nrs which I then use to put into an array. Then I use this array to find any classifieds in a MySql db where the ID:s match the ID:s in the array returned by Solr.

Now, because this array can be very very big (100thousand records or more) then I would need to "page" the results so that maybe 100 where returned at a time. And then use those 100 ID:s in MySql to find the classifieds.

So, is it possible to page with SOLR?

And if so, how? I need example code... And what the results would be please.

Mostly I need a thorough example!

Thanks

A: 

You can make use of the IN clause to retrieve records whose column matches the given IN value.

SELECT col1, col2 FROM tbl WHERE id IN (1, 2, 3, 4, 5)

I'm not sure which programming language / DB access API you're going to use (you tagged both PHP and Java, which is confusing), so I can't give some detailed examples, but to the point, you just need to construct the above query dynamically so that it returns the desired subsets of the results based on "firstindex" and "rowcount".

Hope this helps.

BalusC
A: 

Take a look at IBM. Maybe that will get you on the right course.

Number of results: Specifies the maximum number of results to return.

Start: The offset to start at in the result set. This is useful for pagination.

So you probably want some variation on

<str name="rows">10</str>
<str name="start">0</str>

Your solr client should provide some way to get the total number of results without much trouble.

jasonbar
+1  A: 

Paging is managed with the start and rows parameters, e.g.:

?q=something&rows=10&start=20

will give you 10 documents, starting at the document 20.

About getting other information from MySQL, you're on your own. Me and other people already suggested to you to store everything in Solr to avoid the additional queries to MySQL.

Mauricio Scheffer