Limiting returned rows in Solr

771 views
Skip to first unread message

Serhiy Polyakov

unread,
Nov 25, 2014, 3:56:49 PM11/25/14
to island...@googlegroups.com
Hi,

I need to limit results to 3 rows (total, not per page) in Islandora Solr Search 6.x-12.1.0. I added 'row' parameter  In IslandoraSolrQueryProcessor.inc but it has no effect on the results, I am getting everything:

    $this->solrParams = array(
      'facet' => 'true',
      'facet.mincount' => $facetMinCount,
      'facet.limit' => $facetlimit,
      'qt' => $requestHandler,
      'hl' => isset($keys[0]) ? 'true' : NULL,
      'hl.fl' => isset($keys[0]) ? trim($keys[0]) : NULL,
      'hl.fragsize' => 400,
      'facet.field' => explode(',', $facetFields),
      'rows' => 3,
    );

Adding other parameters there has effect on what they are supposed to do, for example, 'hl.snippets' => 5,


Querying Solr via URL correctly gives me 3 rows:
my.server:8080/solr/select?q=*:*&rows=3


I added to my custom requestHandler in solrconfig.xml:
<int name="rows">3</int>

Still no effect.

Any suggestion about limiting rows?

Serhiy

Diego Pino

unread,
Nov 25, 2014, 5:35:02 PM11/25/14
to island...@googlegroups.com
Hi,

If you turn Solr debugging "On" in Islandora's search config page (admin/islandora/search/islandora_solr/settings), you will see that Solr search is already passing the number of rows to Solr as a parameter. This value is controlled by "Results per page" field/value in the Solr Index config page.

Even if you define a custom requestHandler with a fixed rows value, all parameters passed to a request handler overwrite(always) the default ones defined by you in solrconfig.xml, so you will never get what you wan't this way. By default(please correct me if 'I'm wrong) Solr search module implementation uses the Number of returned Docs from a search to calculated the pagination,not the rows so even when you limit rows to 3, you will always get more pages. You could always write your own Solr search display, but that's another topic.

Good luck

Diego

Serhiy Polyakov

unread,
Nov 26, 2014, 1:49:51 AM11/26/14
to island...@googlegroups.com

Diego,

 

Thanks for clarification. I wanted to restrict the complete results set in order to limit the scope of the facets to that set. However, I realized that there is no way to restrict the compete result set even with rows. This should be done with queries, for example, limiting by ID. Two queries passes would be required for that, first finding IDs and second limiting by IDs.

 

Serhiy

--
You received this message because you are subscribed to the Google Groups "islandora-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Vessey

unread,
Nov 26, 2014, 8:26:32 AM11/26/14
to island...@googlegroups.com
Pretty sure the "solrLimit" member on IslandoraSolrQueryProcessor will override the "rows" value.

- Adam

Diego Pino

unread,
Nov 26, 2014, 8:54:48 AM11/26/14
to island...@googlegroups.com
Right Serhiy,

There is no simple way of limiting facets to only rows. Facets are always calc. for the whole result set.You could of course do some custom coding (a own Solr Display Profile).Getting the first 3 ids and querying again using ID1 OR ID2 OR ID3. This is not most optimal way, but you are only needing a fixed 3 document response, so in terms of performance this should not hurt.

Other option is using field collapsing:


This way you can "group" results by some field. Using this facets are only calculated for the grouped results, but here are a number of limitations. Still hackish. 

Why do you need this?

Diego

Serhiy Polyakov

unread,
Nov 26, 2014, 2:39:59 PM11/26/14
to island...@googlegroups.com
Adam, thanks. Here is my understanding. There are to sets:

(1) complete result set for a query computed and stored on the server
(2) set of documents returned to client which is subset of (1)

"start" and "rows" in Solr or "solrStart", "solrLimit" in Islandora compute set (2) from set (1) for pagination, etc. Solr facets are computed and presented for (1).

Serhiy

Serhiy Polyakov

unread,
Nov 26, 2014, 2:53:59 PM11/26/14
to island...@googlegroups.com
Diego,

Thanks, I was and will be looking at field collapsing as one of the solutions.

Regarding my example... In fact I wanted to limit complete result set for a query to ~50 or so, 3 was just a test number.

My complete set of results in test searches is normally around ~300. There are about 1000 unique facets (subject terms) describing this set. Facets are sorted by number of hits on the left panel of UI. I can economically present only first 20 to 50 facets in UI. But I do not need facets describing low relevant results returned after about document #50.

Perfect solution is to sort facets in some relation to the relevancy (score) of the returned documents set but there is no standard way for that in Solr.

Serhiy

Reply all
Reply to author
Forward
0 new messages