0
down vote
favorite
I'm using nest 2.x with a server ES1.x (my query retuurn correct results now), so to resolve this problem, i need to downgrade nest 2.x to 1.x because it's impossible to have a server 2.x of ES
what's the best practices to do this?
how can I change my query 2.0 to 1.0?
this my code for example:
var mustBaseQuery = new List
{
new ExistsQuery { Field = new Field { Expression = (Expression<Func<DetailsAnnonce, object>>) (p=>p.Prix) } },
// TODO: filtrer les annonces sans ville lors de la synchro
new ExistsQuery { Field = new Field { Expression = (Expression<Func<DetailsAnnonce, object>>) (p=>p.CodePostal) } },
new ExistsQuery { Field = new Field { Expression = (Expression<Func<DetailsAnnonce, object>>) (p=>p.Ville) } },
new NumericRangeQuery
{
Field = new Field { Expression = (Expression<Func<DetailsAnnonce, object>>) (p=>p.Prix)},
GreaterThan = 0
}
};
private TermsAggregate GetTypeBienCountAggregation(DetailsAnnonce detailAnnonce) { // TODO : Assurer que ville n'est JAMAIS NULL var aggs = Client.Search<DetailsAnnonce>(s=>s. Query(q=>q. ConstantScore(c=>c. Filter(f=>f. Term(t=>t. Field(fl=>fl.Ville.Id).Value(detailAnnonce.Ville.Id))))) .Aggregations(a=>a .Terms("type_transaction", tt=>tt .Field(f=>f.TypeTransactionId) .Aggregations(agg=>agg .Terms("type_bien", t=>t .Field(f=>f.TypeBienId) .MinimumDocumentCount(1))))) .Size(0)).Aggs.Terms("type_transaction"); return aggs; }
private void ParseLocationProcheAggregations(MultiBucketAggregate aggs, AnnonceDetailAggregations results)
{
if (aggs != null)
{
foreach (var geoBucket in aggs.Buckets)
{
var quartierIdBuckets = geoBucket.Filter("quartiers_filter").Terms("quartiers_id").Buckets;
var quartierNameBuckets = geoBucket.Filter("quartiers_filter").Terms("quartiers_name").Buckets;
var villeIdBuckets = geoBucket.Terms("villes_id").Buckets;
var villeNameBuckets = geoBucket.Terms("villes_name").Buckets;
for (var i = 0; i < quartierNameBuckets.Count; i++) { int id; if (!int.TryParse(quartierIdBuckets.ElementAtOrDefault(i)?.Key ?? string.Empty, out id)) id = -1;
if (results.QuartiersProches.Any(q => q.Id == id)) continue; results.QuartiersProches.Add(new Localisation { Name = quartierNameBuckets[i].Key, Id = id }); }
for (var i = 0; i < villeNameBuckets.Count; i++) { int id; if (!int.TryParse(villeIdBuckets.ElementAtOrDefault(i)?.Key ?? string.Empty, out id)) id = -1;
if (results.VillesProches.Any(v => v.Id == id)) continue; results.VillesProches.Add(new Localisation { Name = villeNameBuckets[i].Key, Id = id }); } } } }
private void ParseTypeBienAggregations(TermsAggregate typeBienAggs, AnnonceDetailAggregations results) { results.CountByTypeBien = typeBienAggs.Buckets.ToDictionary(b => int.Parse(b.Key), b => b.DocCount ?? 0); }