Take care when 'finding' a Record by number

In a recent post I discussed the FindBy method.  This can significantly reduce the load on a server by eliminating unnecessary requests.  When searching for a record by record number, it is faster to find than to search.

Search Examples

This is faster:

/Record/rec_1?format=json

Than this:

/Record?q=number:rec_1&format=json

FindBy Examples

This is faster:

{
    "RecordTitle": "My Title",
    "RecordContainer": {"FindBy":"REC_1"}
}

Than this:

{
    "RecordTitle": "My Title",
    "RecordContainer": {"FindBy":"number:REC_1"}
}

Caveats

Firstly, if you have numeric record numbers they may clash with the record Uri so you will have to do a search and use the 'number' clause.

Omitting the 'number' clause from a FindBy causes the 'default' search to be used which also includes the title, this may result in false positives.

Summary

On systems under heavy load you may consider avoiding the number clause as long as you write your code to filter out any false positive search results that result from doing so.

Written on December 13, 2016