& in URL in real time search demo coded so link fails

I am testing out an index I built from a Forum. It’s working ok, but the URLs on the demo are have coded the ampersands in the URL so they fail.

I am sending them into the index as a simple & can anyone tell me what I am doing wrong.

If you want to see the problem take a look at

https://www.algolia.com/realtime-search-demo/search-v2

Hello,

Thank you for reaching out !
I can see that the engine is sending back those encoded characters: it means you are pushing those values - with encoded characters - into your algolia index. Two ways of solving that issue, either when you push the data to Algolia, or when you treat the hits you are receiving after a search operation.
I would recommend you to treat those HTML entities before pushing those records to Algolia. Basically, it means looping over your objects, and replace the HTML entities by the right characters (i.e: & by &), and then push the records to Algolia, this will solve the situation :slight_smile:

Let me know if this helps,

I am using the following php with your provided php module

 $topic_link  = "http://www.fhug.org.uk/forum/viewtopic.$phpEx".'?f=' . $posts_row['forum_id'] . '&t=' . $posts_row['topic_id'];
$index->addObject(
  [
'objectID' => $topic_id,
'title' => censor_text($topic_title),
'author'  => $topic_author,
'url'     => $topic_link,
'content' => $all_content
  ]

So should I be converting the & to & ?

Hello back,

I guess you can you html_entity_decode to decode your string before pushing your record to Algolia.
It should convert the encoded ampersands by “&”.

Let me know how it goes,

Just to let you know, the data was correctly recorded in the index, it was the link created in the demo which had been “over-processed” I rolled my own search and it’s working fine.