Hi,
We had requirement that based on doc field and doc value, we want to hide/show return field for other column.
for example,
doc 1
name: mac, category : hardware, active=true, manager=Sam
doc 2:
name: windows, category: hardware, active=true, manager=Bill
doc 3:
name: outlook, category: software, active=true, manager=Bill
and when the user search, we want to show/hide manager field based on conditions like category = software or active=true or both, these are dynamically by the user. We still want the record in our result, but we just want to show/hide that particular manager field.
After researching, i found the script_field is the way to go. IF YOU SUGGESTED ALTERNATIVE, PLEASE LET ME KNOW!!
But if put every thing in the query, the performance would be slow and the code is messy.
So, im thinking pass in fieldnames and field values to the script, and
do a loop of on fieldnames for sth like doc[fieldName] = fieldValue, then return empty. otherwise, return the field value.
Is it possible? I tried pass in that, for a script,
but seems the below script always return false, although the if condition is met.
if (doc[fieldName] == fieldValue) return true; return false;
Also, when i tried to use Debug.explain(); it throws exception with no reason, but just following stack trace:
"script_stack": [
"Debug.explain(fieldName);",
" ^---- HERE"
],
Thanks a lot in advance!