I don’t think that would work, because the literal struct is still invalid.
the way I did it in my code, incidentally also for submitting a query to
ElasticSearch, is by building a struct with the conditions, and then at
the end serializing it to JSON. so instead of savecontent, I actually
added keys and values to the struct according to the conditions.
the problem is at
|*{ #filtri# }*|
the parser sees it as a single item, which would be expected in an
Array but not in a Struct. This is invalid just like
{ invalid }
is not a valid Struct, but
{ state: valid }
is a valid one.
if it were an Array, then it would be
[ valid ]
which is also valid.
makes sense?
Igal Sapir
Lucee Core Developer
Lucee.org <http://lucee.org/>
On 3/30/2016 12:18 PM, Ivan wrote:
Hi,
I'm doing this:
|
// estrago le info sulla categoria
catInfo = catConvert(Trim(arguments.categoria));
// creo i filtri di ricerca
savecontent variable="filtri" {
// se è una ricerca con filtri
if ( !catInfo.all ) {
// cerca tutta la categoria
if (catInfo.padre == 1) {
writeOutput('
"and":[
{
"term":{
"pro_cat": ' & catInfo.IdCat & '
}
}
]
');
} else {
// cerca solo nella sottocategoria
writeOutput('
"and":[
{
"term":{
"pro_cat_id": ' & catInfo.IdUni & '
}
}
]
');
} // if secondaria
} // if principale
}; // savecontent
variables.searchParams = [];
variables.searchParams = {
"from":0,
"size":150,
"query":{
"filtered":{
"query":{
"multi_match":{
"query":"#searchUrlToString(arguments.searchText)#",
"type": "most_fields",
"fields":[
"pro_titolo^10",
"pro_descrizione",
"pro_brand"
]
}
},
*"filter": { #filtri# }*
}
}
};
|
*and I get this error */(at red line)/*:*
invalid argument for literal struct, only named arguments are
allowed like {name:"value",name2:"value2"}
I can not solve ... Can anyone make me understand?
--
Love Lucee? Become a supporter and be part of the Lucee project
today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the
Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to lucee+unsubscribe@googlegroups.com
<mailto:lucee+unsubscribe@googlegroups.com>.
To post to this group, send email to lucee@googlegroups.com
<mailto:lucee@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/df3c1e6f-1d73-4e08-8b3a-cd9d8e131752%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Love Lucee? Become a supporter and be part of the Lucee project
today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google
Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to lucee+unsubscribe@googlegroups.com
<mailto:lucee+unsubscribe@googlegroups.com>.
To post to this group, send email to lucee@googlegroups.com
<mailto:lucee@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/56FC2882.3030700%40lucee.org
<https://groups.google.com/d/msgid/lucee/56FC2882.3030700%40lucee.org?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
–
Love Lucee? Become a supporter and be part of the Lucee project today!