Tuesday, 15 June 2010

c# - Nest renders range boundaries as string instead of double -


I am interrogating ElasticSearch with this code, with the nest:

  Var mustTerms = new list & lt; Funk & lt; Query descriptor & lt; Elasticcake in & gt; Nest. Cotainier & gt; & Gt; (); Var dmaxprice = maxprice.hasValue? (Double?) MaxPrice.Value: 100000d; Var dminPrice = minPrice.HasValue? (Double?) MinPrice.Value: 0D; Should be Tarma.Ad (MT => MT range (RD => rd.OfField ("value"). Lower Oracles (DMXPrice) .GreaterOrEquals (dminPrice)); Function & lt; Query descriptor & lt; Elastickeyk in & gt; Nest.QueryContainer & gt; QueryFunc = qd = & gt; Qd. FunctionsCon (fsq = & gt; fsq .Query (fsqd = & gt; fsqd.bool (bqd = & gt; bqd.) (Must be .torms.a) (should be Terms.ToArray ()). Functions (fsd = & Gt; FSD.Linator ("createDate", fsdfd = & gt; FSDFD Scalail ("1D"). (0.5D) Original (Date Time. UTCNOOoostring ("O")))); Funk & lt; Search descriptor & lt; Elastic Check In & gt; Search descriptor & lt; Elastic Check In & gt; & Gt; SearchFunc = q = & gt; Q. Index (_indexName). Type (_typeName) .Query (queryFunc). size range);  

This code generates the query:

  {"query": {"function_score": {"functions": [{"linear": { "" "": "" "" ":" "" "": [["Category": {"value": {"gte": "29.97", "lte": "67.5 "}}}}}}}}}  

As you can see, the nest range represents a double value in the form of a wire:

  

<" When I correct double values ​​by hand, Elasticsearch returns query results correctly

Update:

This Mapping for Index:

  {"Matrix": {"Matteps": {"Properties": {"Properties": {"createDate": {"Type": "Date", "Format": "Detautical / "Other" fields: / "other"), "id": {"type": "string"}, / * other fields * / "value": {"type": "long"} / * other fields *}}}}}  

We did not map the value area in particular, there are some value field integers on Docs, some couples.

This bug may be a bug in using a syntax that you choose, Problems can arise. To represent your ES data, a more standard syntax would be to create a C # POCO like this:

  [elastic type] public class type1 {public string id {get; Set; } Public date time creation date {receive; Set; } Public double value {receipt; Set; }}  

With it, your query syntax becomes much simpler:

  var result2 = Elastic client Search & lt; Type1 & gt; (S => Objectivity (q = & gt; q.filtrated (f => f.filters (ff => ff .range (r = & gt; rffffffffffffffff = & gt; ; RF value) .GreaterOrEquals (29.97) .lower o'clock (67.5))))));  

No comments:

Post a Comment