Search - no items returned when searching company number for items_per_page=1

The code here must have changed as the behaviour’s changed but it’s still not quite right!

If you call the search end-point and specify items_per_page as 1 and don’t specify a start_index, the second result in the list is returned. This seems to happen because start_index is incorrectly being set to 1 when you specify items_per_page as 1. For other values of items_per_page (or if you don’t specify it at all) start_index is set to zero (which is where it should start).

Example (the “normal” order can be seen by performing the search in CH Beta e.g. https://beta.companieshouse.gov.uk/search/companies?q=Wiselan%20Ltd):

First:
items_per_page = 1
Note: the entry returned is WISELAND LIMITED (09990271). In the returned object start_index is given as 1, and page_number as 2.

curl -u%APIKEY%: “https://api.companieshouse.gov.uk/search/companies?q=WISELAN%20LTD&items_per_page=1”

{
“kind”: “search#companies”,
“total_results”: 4,
"page_number": 2,
"start_index": 1,
“items_per_page”: 1,
“items”: [ {
“date_of_creation”: “2016-02-05”,
“address”: { … },
“title”: “WISELAND LIMITED”,
“company_number”: “09990271”,
“matches”: { … },
“address_snippet”: …,
“links”: { … },
“company_type”: “ltd”,
“kind”: “searchresults#company”,
“description”: “09990271 - Incorporated on 5 February 2016”,
“company_status”: “active”,
“description_identifier”: [ “incorporated-on” ],
“snippet”: “”
} ]
}

How it should work:
items_per_page = 3. Note the top entry = WISELAN LIMITED (03765830) - the correct “top” entry. In the return start_index = 0 and page_number = 1 as expected.

curl -u%APIKEY%: “https://api.companieshouse.gov.uk/search/companies?q=WISELAN%20LTD&items_per_page=3”

{
“kind”: “search#companies”,
“items_per_page”: 3,
“total_results”: 4,
“items”:
[
{
"company_number": “03765830”,
"title": “WISELAN LIMITED”,
…
},
{
“company_number”: “09990271”,
“title”: “WISELAND LIMITED”,
…
},
{
“title”: “WISELAND CONSTRUCTION LIMITED”,
“company_number”: “03259344”,
…
}
],
"start_index": 0,
"page_number": 1
}

Going down one- items_per_page = 2 - gives the same order as above (e.g. without “WISELAND CONSTRUCTION LIMITED”) and the start_index is 0 still.

Trying to force the issue by deliberately setting both items_per_page = 1 and start_index = 0 doesn’t help:

curl -u%APIKEY%: “https://api.companieshouse.gov.uk/search/companies?q=WISELAN%20LTD&items_per_page=1&start_index=0”

{
“page_number”: 2,
“kind”: “search#companies”,
“items_per_page”: 1,
“total_results”: 4,
“items”: [
{
“title”: “WISELAND LIMITED”,
“company_number”: “09990271”,
“company_type”: “ltd”,
…
}],
“start_index”: 1
}