Invalid argument for literal struct

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?

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!


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
https://groups.google.com/d/msgid/lucee/df3c1e6f-1d73-4e08-8b3a-cd9d8e131752%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

Not sure if this will work, but I’d try putting the braces { } inside the
savecontent block and then do:

“filter”: #filtri#

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamediaOn Wed, Mar 30, 2016 at 9:26 PM, Igal @ Lucee.org <@Igal> wrote:

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.
To post to this group, send email to 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?utm_medium=email&utm_source=footer
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.
To post to this group, send email to 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.

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.

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/On 3/30/2016 1:15 PM, Nando Breiter wrote:

Not sure if this will work, but I’d try putting the braces { } inside
the savecontent block and then do:

“filter”: #filtri#

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Wed, Mar 30, 2016 at 9:26 PM, Igal @ Lucee.org <@Igal mailto:Igal> wrote:

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!


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/CAGHrs%3D-16jVqcLWYi2HTvUVQ6dQPPgQ_%3D96A9uK%2BqGHDbZMVuw%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-16jVqcLWYi2HTvUVQ6dQPPgQ_%3D96A9uK%2BqGHDbZMVuw%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

Actually, I take that back. I didn’t read Nando’s message properly. It
might as well work.On 3/30/2016 1:52 PM, Igal @ Lucee.org wrote:

I don’t think that would work, because the literal struct is still
invalid.

Hi everyone,

I tried the solution: “filter”: #filtri# but it is passed as a string. Look:

https://lh3.googleusercontent.com/-AU2hYnjbMdE/VvzHVers-HI/AAAAAAAACpM/UJ-mI5bxa68jr9P3f87C4lMqMLkOLYAgQ/s1600/err.png