Highlight Issue

Hello,

Just started using Algolia API, thanks for making the setup process simple with all the examples.

However, I’ve just spent hours struggling with a very simple issue. The display attribute cannot contain uppercase letters (unless I am mistaken). My csv first line (attributes) had uppercase letters and in the browser console I kept having this “Uncaught TypeError: Cannot read property ‘value’ of undefined”

Maybe it’s super obvious, actually I’m am a newbie at code, I don’t mind at all if uppercase letters are technically not permitted but it would be worth mentioning this in the getting started code comments or so.

Hope this can help !

Thanks otherwise, dashboard & search perfect .

Hi there,

Would you mind copy/pasting an example code that doesn’t work.
If it can not be shared publicly feel free to drop an email at support@algolia.com

Best,

Hi remy,

Thanks for your answer, I actually figured out the problem was not an uppercase issue but the fact that I had manually set up the Attributes to Highlight in the dashboard AND in the code.

If you open the console here you will find the same error : https://jsfiddle.net/9apqaeut/4/

Thanks

Hours later I am still trying to figure out why attributestohighlight doesn’t respond correctly.

My dashboard settings are set with the correct attributestoHighlight (code) but here is the response I get, with no override :

REQUEST :

{
“params”: “query=45&hitsPerPage=5”
}

RESPONSE ;

{
“hits”: [
{
“code”: 45000,
“ville”: “LOIRET”,
“shipzone”: 0,
“objectID”: “2828162”
}
],
“nbHits”: 1,
“page”: 0,
“nbPages”: 1,
“hitsPerPage”: 5,
“processingTimeMS”: 1,
“exhaustiveNbHits”: true,
“query”: “45”,
“params”: “query=45&hitsPerPage=5”
}

Thanks for your help, it’s probably very simple but I’m struggling like mad

It looks like changing the settings in the dashboard have no impact on the query results. When I add a highlight attribute in the dashboard settings and then I browse in RAW from the dashboard , it says “attributesToRetrieve”: “*”, and no highlight.

Hi ,

Maybe this is more precise for you. Here’s the response I get in the log when I do a javascript query. You can see in the params line that attributestoHighlight have been requested but the response doesn’t have them. Any idea ?

{
“hits”: [
{
“code”: 42000,
“ville”: “LOIRE”,
“shipzone”: 0,
“objectID”: “2828132”
}
],
“nbHits”: 1,
“page”: 0,
“nbPages”: 1,
“hitsPerPage”: 6,
“processingTimeMS”: 1,
“exhaustiveNbHits”: true,
“query”: “42”,
“params”: “query=42&attributesToRetrieve=%5B%22code%22%2C%22ville%22%2C%22shipzone%22%5D&attributesToHighlight=%5B%22code%22%5D&hitsPerPage=6”
}

Okay finally figured out the real issue with my database, the number values in the source json were not in a string format (i.e : 5465 instead of ‘5465’) and it looks like they can’t be highlighted if they are not in a string format + other problems along the way.

1 Like