# Challenges while migrating elasticsearch client 6.8 to 8.7 (is mandatory)

**URL:** https://discuss.elastic.co/t/challenges-while-migrating-elasticsearch-client-6-8-to-8-7-is-mandatory/349856
**Category:** Elasticsearch
**Created:** [December 22, 2023, 1:36pm UTC](https://discuss.elastic.co/t/challenges-while-migrating-elasticsearch-client-6-8-to-8-7-is-mandatory/349856 "2023-12-22T13:36:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Chetan\_Ramaiah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chetan_ramaiah/32/48571_2.png) [@Chetan\_Ramaiah](https://discuss.elastic.co/u/Chetan_Ramaiah)
#### Post date: [December 22, 2023, 1:36pm UTC](https://discuss.elastic.co/t/challenges-while-migrating-elasticsearch-client-6-8-to-8-7-is-mandatory/349856/1 "2023-12-22T13:36:39Z")

</div>

Hello,

Currently, I am in the midst of transitioning from Elasticsearch HLRC 6.8 to Elasticsearch REST API Java Client 8.7 within a Spring Boot application. This migration aligns with the broader upgrade of the Spring version from 5.5 to 6.1.

Following the upgrade to Spring version 6, I've observed widespread failures, ranging from Spring Data to Elasticsearch and the generation of Elasticsearch queries.

I haven't come across any comprehensive documentation that could provide assistance.

The following query is generated using Elasticsearch HLRC 6.8. Could you please guide me on how to generate this query using the Elasticsearch 8.7 Java REST API client?

```auto
{
	"size": 0,
	"query": {
		"bool": {
			"must": [
				{
					"bool": {
						"should": [
							{
								"terms": {
									"ex_desc": [
										"bus"
									],
									"boost": 1.0
								}
							},
							{
								"terms": {
									"ex_desc": [
										"truck"
									],
									"boost": 1.0
								}
							}
						],
						"adjust_pure_negative": true,
						"boost": 1.0
					}
				},
				{
					"bool": {
						"should": [
							{
								"bool": {
									"must": [
										{
											"terms": {
												"mstate": [
													"OE"
												],
												"boost": 1.0
											}
										},
										{
											"bool": {
												"should": [
													{
														"terms": {
															"mtype": [
																"GENERAL"
															],
															"boost": 1.0
														}
													},
													{
														"terms": {
															"mtype": [
																"Need to check"
															],
															"boost": 1.0
														}
													},
													{
														"terms": {
															"mtype": [
																"Unknown"
															],
															"boost": 1.0
														}
													},
													{
														"terms": {
															"mtype": [
																"NA"
															],
															"boost": 1.0
														}
													}
												],
												"adjust_pure_negative": true,
												"boost": 1.0
											}
										}
									],
									"adjust_pure_negative": true,
									"boost": 1.0
								}
							},
							{
								"terms": {
									"mstatus": [
										"Active now"
									],
									"boost": 1.0
								}
							},
							{
								"terms": {
									"mstatus": [
										"Unknown"
									],
									"boost": 1.0
								}
							}
						],
						"adjust_pure_negative": true,
						"boost": 1.0
					}
				}
			],
			"filter": [
				{
					"range": {
						"spent_charges": {
							"from": "0",
							"to": null,
							"include_lower": true,
							"include_upper": true,
							"boost": 1.0
						}
					}
				},
				{
					"terms": {
						"email.keyword": [
							"abcm@ras.com",
							"pjhsk@ras.com"
						],
						"boost": 1.0
					}
				},
				{
					"terms": {
						"source": [
							"SCR1",
							"SCR2",
							"SCR3",
							"SCR4"
						],
						"boost": 1.0
					}
				},
				{
					"range": {
						"start_date": {
							"from": "2022-11-01",
							"to": null,
							"include_lower": true,
							"include_upper": true,
							"boost": 1.0
						}
					}
				},
				{
					"terms": {
						"deleted": [
							"N"
						],
						"boost": 1.0
					}
				}
			],
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	},
	"aggregations": {
		"unique_email": {
			"cardinality": {
				"field": "email.keyword"
			}
		},
		"staff": {
			"terms": {
				"field": "email.keyword",
				"size": 10000,
				"min_doc_count": 1,
				"shard_min_doc_count": 0,
				"show_term_doc_count_error": false,
				"order": [
					{
						"totalspent": "desc"
					},
					{
						"_key": "asc"
					}
				]
			},
			"aggregations": {
				"Num": {
					"cardinality": {
						"field": "number.keyword"
					}
				},
				"totalexp": {
					"sum": {
						"field": "spent_charges"
					}
				},
				"distinct": {
					"top_hits": {
						"from": 0,
						"size": 1,
						"version": false,
						"seq_no_primary_term": false,
						"explain": false,
						"_source": {
							"includes": [
								"all_uid",
								"name",
								"age",
								"email",
								"status"
							],
							"excludes": []
						}
					}
				},
				"expsort": {
					"bucket_sort": {
						"sort": [],
						"from": 0,
						"size": 10,
						"gap_policy": "SKIP"
					}
				}
			}
		}
	}
}

```

Thanks in advance  
Chetan

---

<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: [January 19, 2024, 1:37pm UTC](https://discuss.elastic.co/t/challenges-while-migrating-elasticsearch-client-6-8-to-8-7-is-mandatory/349856/2 "2024-01-19T13:37:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
