# Downgrade nest 2.xx to 1.xx

**URL:** <https://discuss.elastic.co/t/downgrade-nest-2-xx-to-1-xx/56109>\
**Category:** Elasticsearch\
**Created:** [July 21, 2016, 2:22pm UTC](https://discuss.elastic.co/t/downgrade-nest-2-xx-to-1-xx/56109 "2016-07-21T14:22:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramzi\_Darmoul](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Ramzi\_Darmoul](https://discuss.elastic.co/u/Ramzi_Darmoul)\
**Post date:** [July 21, 2016, 2:22pm UTC](https://discuss.elastic.co/t/downgrade-nest-2-xx-to-1-xx/56109/1 "2016-07-21T14:22:41Z")

</div>

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);
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:33pm UTC](https://discuss.elastic.co/t/downgrade-nest-2-xx-to-1-xx/56109/2 "2017-07-05T22:33:40Z")

</div>

Closed on July 5, 2017, 10:33pm UTC


