How do i use the range search in elastic?
I tried to use the code from price and news, but can’t get it to work.
I have tried alot of different ways, but i never get any result back.
Tried to have the field Nested, and not Nested. I tried it on the regular Tags, and i have saved all numeric values in a seprate property and tried that. I have tried with and without keyword on key and value.
[Nested]
public List<NumericTagItem> NumericTags { get; set; } = new List<NumericTagItem>();
public class NumericTagItem
{
[Keyword]
public string Key { get; set; }
[Keyword(EagerGlobalOrdinals = true)]
public double Value { get; set; }
}
These are the queries i have tried:
allQueries.Add(qc.Bool(b =>
b.Filter(bf =>
bf.Range(r =>
r.Field(x => x.NumericTags.Find(t => t.Key == tag.Key).Value)
.GreaterThanOrEquals(minValue)
.LessThanOrEquals(maxValue)))));
allQueries.Add(qc.Range(b =>
b.Field(x => x.NumericTags.Find(t => t.Key == tag.Key).Value)
.GreaterThanOrEquals(minValue)
.LessThanOrEquals(maxValue)));
allQueries.Add(qc.Nested(n => n
.Path(x => x.NumericTags)
.Query(nq
=> nq.Range(t => t.Field(f => f.NumericTags.Find(tt => tt.Key == tag.Key).Value)
.GreaterThanOrEquals(minValue)
.LessThanOrEquals(maxValue)))));
allQueries.Add(qc.Bool(b => b.Filter(bf => bf.Bool(bb => bb.Should(q => q.Nested(n => n
.Path(x => x.NumericTags)
.Query(nq => nq.Range(t => t.Field(f => f.NumericTags.FirstOrDefault(tt => tt.Key == tag.Key).Value)
.GreaterThanOrEquals(minValue)
.LessThanOrEquals(maxValue))
)))))));
Litium version: 8.2