When uploading CSV files to Algolia, numeric fields such as age or price must be properly formatted to ensure they are indexed as integers rather than strings.
Why this matters
If numeric values contain leading or trailing spaces, Algolia may interpret them as text (strings) instead of numbers. This can lead to incorrect behavior when:
- Sorting results
- Applying numeric filters
- Performing range queries
Example of incorrect formatting
name,age,department
James, 28,IT
Jessica,32 ,Sales
Anne,23,Engineering
In this example, the values for James and Jessica include extra spaces, which can cause them to be indexed as strings.
Correct formatting
To ensure these fields are treated as integers, remove any unnecessary spaces:
name,age,department
James,28,IT
Jessica,32,Sales
Anne,23,Engineering
Best practice
Before uploading your CSV file:
- Check that all numeric fields contain only numbers
- Remove any leading or trailing whitespace
- Validate your data formatting to ensure consistency across records
Proper formatting ensures that Algolia correctly indexes numeric values, enabling accurate filtering, sorting, and overall search behavior.