How to Set Default Integer Value in Search Template

I am getting a number_format_exception when trying to run a search against a search template containing this snippet of code. It defines a CityID variable and tries to set a wildcard default and the CityID field is defined as an integer in my mapping:

{{CityID}}{{^CityID}}*{{/CityID}}

Basically, I am trying to make the CityID field optional in my search template and the string fields work fine when using the *. Does anyone know what the wildcard default for a integer variable should be? Just as a test I set it to 0 and re-ran the search and it worked but did not return any results because I have no Cities with a CityID of 0 and obviously I cannot make that the default. I just wanted to confirm that the definition is in fact expecting an integer value. Any help would be appreciated. Thanks.

Kevin

This issue is resolved and it was fixed by changing my search template definition for CityID to this:

{{#CityID}}{{.}}{{/CityID}}{{^CityID}}0{{/CityID}}

This basically says use the CityID value if it is passed into the search template (represented by the period place holder) or use the value of 0 if no value is passed. This works for me because this portion of the search template is in a should clause and I have no Cities with a CityID of 0. Just thought I would post an update in case anyone else runs into this issue.

Kevin

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.