Data source filter not recognising space character

(Sean) #1

Matrix Version:
Hi all

Having an issue with filtering of a JSON data source. Spaces in a filter parameters value are causing some unexpected results.

I have a JSON data source whose results are displayed on a page using an asset listing. I then use a form to pass user entered data via get variables to Dynamic inputs and then use record filtering to allow searching of the data source.
As soon as I enter a search value with a space however the search fails to produce the correct results. Below are a couple of examples of the issue and the results

1st example case

Searching for an ‘Address’ of ‘38’ works, searching for an address of ‘Patterson’ works, but searching for ‘38 Patterson’ returns only the records whose address is empty (somehow matching the space to the empty value or something?).

2nd example case

Searching for a ‘District’ of ‘Canberra’ works, Searching for a ‘District’ of ‘Central’ works but searching for a ‘District’ of ‘Canberra Central’ returns zero.

In both cases, in the URL get parameter, Squiz seems to replace the space with a ‘+’ symbol. So for the second example above the URL ends up as http://www…?district=Canberra+Central.

Tried manually replacing the ‘+’ in the URL with the URL character code for a space, %20, but this fails to produce the expected result as well.

Is this a known issue and if so is there a work around?
Otherwise any suggestions on what may be causing this issue?

Thank you

(Sean) #2

In addition to the previous post , it seems that the data source filter may have issues with NULL values as well.

Our JSON data source has NULL values for some fields and when trying to filter on those fields all of the records with NULL values for that field get returned in addition to any records that actually match the filter criteria.

Using a filter value of ‘ACME’ in a company field would return any record matching ‘ACME’ as well as any record where the company field equals NULL.

Wondering if anyone can shed any light on this issue as well?


(Bart Banda) #3

Hi Sean, for the first issue, does it work if you hardcode the query in the JSON data source? Reason I’m asking is if that works, then maybe you can do a keyword replacement on the + or %20 with a space if you are getting the value dynamically from the URL on the frontend?

For the second issue, it might be worth sending a ticket in to Squiz support to see if they can help figure it out and if not, report a bug to the product team.

(Sean) #4

Thanks for the response Bart.

I just wanted to finalise this for anyone else having the issue.

We never managed to get the filter to work right for the cases in my examples above.

We ended up doing it in SSJS and and filtering at the API level before returning the (filtered) JSON back to Matrix.
Probably a cleaner and definitely more optimised solution but the initial idea was to keep the filtering as simple as possible and not overcomplicate so using the built in data source filtering seemed like the perfect solution. In the end it wasn’t achievable for us though.