Skip to content

Bug in TermsQueryDescriptor when passing to Terms IEnumerable<TValue> #1930

Closed
@alekole

Description

@alekole

if i have some descriptor like
var descr = new QueryContainerDescriptor<SearchProductCard>().Terms(t => t.Field("field").Terms(new List<int> {1,2}));

it will transfer in

"terms": {
     "field": [
        [
             "1",
             "2"
         ]
      ]
   }

This causes an error in elastic

"reason": {
               "type": "number_format_exception",
               "reason": "For input string: \"[\""
            }

I have noticed that before commit e1e467e2 there was an explicit conversion to array

public TermsQueryDescriptor<T, K> Terms(IEnumerable<K> terms) => Assign(a =>  
    {
    if (terms.HasAny())
    terms = terms.Where(t => t != null).ToArray();
    a.Terms = terms.Cast<object>();
});

and missed later

public TermsQueryDescriptor<T, TValue> Terms(IEnumerable<TValue> terms) => Assign(a => a.Terms = terms.Cast<object>());

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions