In case anyone else needs the answer, I was able to make it work with:

        {
          "filtered": {
            "filter": {
              "script": {
                "script": "doc['currentPatchSet.parents'].values.size() == 
1"
              }
            }
          }
        }

Hope that helps.

e.

On Monday, July 28, 2014 10:36:05 AM UTC-6, Eric Brunson wrote:
>
> I found what I think should work in a script filter, but I get an access 
> exception trying to use it.
>
> Adding the following filter:
>
>         {
>           "filtered": {
>             "filter": {
>               "script": {
>                 "lang": "mvel",
>                 "script": "doc['currentPatchSet.parents'].values.length < 
> param1",
>                 "params": {
>                   "param1": 2
>                 }
>               }
>             }
>           }
>         }
>
>
> Ends up with the following error(s) at the bottom of the traceback:
>
> {
>    "error": "SearchPhaseExecutionException[Failed to execute phase 
> [query], all shards failed; shardFailures 
> {[yCmFfug8TdK15SxsAUSrww][gerrit_v2][0]: 
> QueryPhaseExecutionException[[gerrit_v2][0]: query[filtered(+status:merged 
> +ConstantScore(cache(BooleanFilter(currentPatchSet.parents:[* TO *]))) 
> +ConstantScore(ScriptFilter(doc['currentPatchSet.parents'].values.length < 
> param1)))->cache(_type:changes)],from[0],size[10]: Query Failed [Failed to 
> execute main query]]; nested: 
> IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1];
>  
> }{[in46F5VZQLCoUF0NyBv_Kg][gerrit_v2][1]: RemoteTransportException[[En 
> Sabah Nur][inet[/10.226.73.179:9300]][search/phase/query]]; nested: 
> QueryPhaseExecutionException[[gerrit_v2][1]: query[filtered(+status:merged 
> +ConstantScore(cache(BooleanFilter(currentPatchSet.parents:[* TO *]))) 
> +ConstantScore(ScriptFilter(doc['currentPatchSet.parents'].values.length < 
> param1)))->cache(_type:changes)],from[0],size[10]: Query Failed [Failed to 
> execute main query]]; nested: 
> IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1];
>  
> }{[gEShLR_-SnK2d7RiQaaMjA][gerrit_v2][3]: 
> RemoteTransportException[[Bounty][inet[/10.226.73.178:9300]][search/phase/query]];
>  
> nested: QueryPhaseExecutionException[[gerrit_v2][3]: 
> query[filtered(+status:merged 
> +ConstantScore(cache(BooleanFilter(currentPatchSet.parents:[* TO *]))) 
> +ConstantScore(ScriptFilter(doc['currentPatchSet.parents'].values.length < 
> param1)))->cache(_type:changes)],from[0],size[10]: Query Failed [Failed to 
> execute main query]]; nested: 
> IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1];
>  
> }{[o6oUK9rhRSinAyFDaAni5g][gerrit_v2][2]: 
> RemoteTransportException[[Jolt][inet[/10.226.73.177:9300]][search/phase/query]];
>  
> nested: QueryPhaseExecutionException[[gerrit_v2][2]: 
> query[filtered(+status:merged 
> +ConstantScore(cache(BooleanFilter(currentPatchSet.parents:[* TO *]))) 
> +ConstantScore(ScriptFilter(doc['currentPatchSet.parents'].values.length < 
> param1)))->cache(_type:changes)],from[0],size[10]: Query Failed [Failed to 
> execute main query]]; nested: 
> IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1];
>  
> }{[in46F5VZQLCoUF0NyBv_Kg][gerrit_v2][4]: RemoteTransportException[[En 
> Sabah Nur][inet[/10.226.73.179:9300]][search/phase/query]]; nested: 
> QueryPhaseExecutionException[[gerrit_v2][4]: query[filtered(+status:merged 
> +ConstantScore(cache(BooleanFilter(currentPatchSet.parents:[* TO *]))) 
> +ConstantScore(ScriptFilter(doc['currentPatchSet.parents'].values.length < 
> param1)))->cache(_type:changes)],from[0],size[10]: Query Failed [Failed to 
> execute main query]]; nested: 
> *IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1]*;
>  
> }]",
>    "status": 500
> }
>
>
> It that some sort of typing I can get around?
>
> Thanks for any help.
>
> Sincerely,
> e.
>
>
> On Friday, July 25, 2014 4:03:45 PM UTC-6, Eric Brunson wrote:
>>
>> I have a doc type which includes a field that is a list of strings.  I'd 
>> like to query/filter based on the number of items in the list, either 
>> exactly equal to n or greater than/less than.  Is that possible?  I haven't 
>> found anything in the Query DSL that seems to lend itself to that.
>>
>> Thanks!
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/22570a37-b4a4-413a-8bb5-390dba0b7bff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to