MultiMatchQuery for Nested Json object search

I'm trying to search Address object with nested attribute using MultiMatchQuery. But I'm getting following error. Great if some one can help on it.

Document in ES index
```
{
"_index": "admin-order-v1-test4",
"_type": "_doc",
"_id": "4bf27333-fb5c-4956-aa3b-a48e0562e3f3",
"_score": 1.0,
"_source": {
"id": "4rrrwf4-fb5c-4956-aa3b-323423dsfsds",
"createdAt": 1588650264000,
"fromAddress": {
"street": "abc",
"streetNumber": "16",
"latitude": null,
"longitude": null,
"zipCode": "13796",
"city": "Stockholm",
"countryCode": "SE"
}
}


**Query in spring boot** : 

BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();

if (queryMap.get("fromAddress") != null) {
queryBuilder.filter(
QueryBuilders.multiMatchQuery("fromAddress",
"fromAddress.street",
"fromAddress.streetNumber",
"fromAddress.latitude",
"fromAddress.longitude",
"fromAddress.zipCode",
"fromAddress.city",
"fromAddress.countryCode")
.type(Type.MOST_FIELDS));
}

SearchSourceBuilder searchSource =
SearchSourceBuilder.searchSource()
.query(queryBuilder)
.explain(true)
.sort(SortBuilders.fieldSort("createdAt").order(SortOrder.DESC))
.from(Integer.parseInt(queryMap.get("page")))
.size(
Math.min(Integer.parseInt(queryMap.get("size")), MAXIMUM_NUMBER_OF_HITS_PER_PAGE));

SearchRequest searchRequest =
new SearchRequest(elasticSearchProperties.getIndex())
.searchType(SearchType.DFS_QUERY_THEN_FETCH)
.source(searchSource);


I'm Getting following error:

"ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]"

Welcome!

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

Finally, please provide the full log or the full error as this is not saying much:

"ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]"

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