What does the "matches" dict returned in a company search tell me?

Hi team,

I ran a search query and in the results returned I see the following dict - what does it tell me?

Thanks.

"matches": {
        "snippet": [
          1,
          9,
          11,
          18,
          20,
          25,
          29,
          37,
          47,
          54
        ],
        "title": [
          1,
          9,
          11,
          16,
          18,
          25
        ]
      }

If you want to know why you got this specific data in this context then you’ll need to post the complete member of the items array, not just the “matches” part (and maybe the endpoint you called / what you searched for.)

If you want to know what this means in general see the docs at:

The exact details of what you’ve found may vary depending on what type of “search result” you’ve found. This can be found in the kind member.

  • Called the “Search” endpoint? You’ll get Company and Officer results (and disqualified officers?)
  • Called the “Company”, “Officer” or “Disqualified Officer” endpoints? You’ll only get results of that type.

The docs spell it out for you:

items[].matches.title
An array of character offset into the title string. These always occur in pairs, and define the start and end of substrings in the member title that matched the search terms. The first character of the string is index 1.

items[].matches.snippet
An array of character offset into the snippet string. These always occur in pairs, and define the start and end of substrings in the member snippet that matched the search terms. The first character of the string is index 1.

items[].matches.address_snippet
An array of character offset into the address_snippet string. These always occur in pairs, and define the start and end of substrings in the member address_snippet that matched the search terms.

items[].title
The title of the search result.

items[].snippet
Summary information for the result, showing additional details that have matched. In the case of companies, this would be previous company names.

items[].address_snippet
A single line address. This will be the address that matched within the indexed document, or the primary address otherwise (as returned by the address member).

A couple of examples - this is my query (using curl):

curl -uMY_API_KEY: "https://api.companieshouse.gov.uk/search/companies?q=bank

The response (I’ve cropped out members which are not relevant):
{
“items”: [
{
“matches”: {
“title”: [
1,
4
],
“snippet”: [ ]
},
“title”: “BANK LTD”,
“snippet”: “”,
“address_snippet”: “Hesketh House, 43-45 Portman Square, London, W1H 6HN”,
…
},
{
“matches”: {
“snippet”: [
8,
11
],
“title”: [
1,
4
]
},
“title”: “BANK AND CLIENTS PLC”,
“address_snippet”: “30 King Street, London, EC2V 8EH”,
“snippet”: "VIRGIN BANK ",
…
},
…
]
}

Not sure if it’s significant but if the snippet was a blank string you seem to get the snippet member of the matches object returned as an empty array.

Thanks for the detailed explanation @voracityemail. Sorry for the delayed response, was moving house! :slight_smile:

I’ll go through the links and see how I get on.

Many thanks