How to clean your data
You can clean data:- Before you send your records for indexing. Make sure your data is safe. This helps protect your app and users from possible security risks like cross-site scripting (XSS) attacks.
-
When showing results.
By default, Algolia includes all attributes in the response, even if you donβt show them.
To exclude attributes from the response,
set them as
unretrievableAttributes
. - As users type into search. Any HTML or code they may enter in the search box exposes you to an XSS attack because Algolia sends the query back in the response.
- Identify sensitive data. Determine which parts of your records could potentially be harmful if misused. This includes any user-generated content or records that include special characters or scripts.
-
Determine how to clean potentially harmful data.
This could involve preventing code injection
by detecting and removing scripts,
and replacing special HTML characters such as
<
and>
with their entity name or number.
How Algolia helps
Algolia ignores HTML tags during search. For example, your records might contain the HTML tag<strong>
:
JSON
- Control characters (U+0000 to U+001F)
- Delete character (U+007F).