LibreCat / Catmandu-Solr

https://metacpan.org/release/Catmandu-Solr
0 stars 4 forks source link

fix slice and counts, and add modifiers #13

Open nicolasfranck opened 7 years ago

nicolasfranck commented 7 years ago

when computing the appropriate start en limit values for solr, when doing a slice, one should remain within the boundaries of a previous slice; the same for count.

nicolasfranck commented 7 years ago

Remark: the combination of a slice and select can be tricky

a select->slice is not the same as slice->select.

Consider this array: 0,1,2,3,4,5,6,7,8,9

This is in fact what would happen if the Solr package did not implements these methods, and the default slice and select would happen (using the generator).

I had a look at how Rails does this, and it's not different there:

Model.limit(2).offset(1).where( "foo" => "bar)

creates the same query as

Model.where( "foo" => "bar).limit(2).offset(1)

Not what todo in such situations. In normal cases select->slice is used?

nicolasfranck commented 7 years ago

What should work already:

slice->slice ..
select->select
select->slice

This..

slice->select

should be fixed by adding an extra check in the "around select" modifier: only if start is 0 and total not provided (read: no slice), should one generate a new Searcher-object . See latest commit.