I have Java code:
List<Recipient> searchRecipients = new ArrayList<>();
SearchRequest idSearchRequest = new SearchRequest("test");
SearchSourceBuilder idSearchSourceBuilder = new SearchSourceBuilder();
QueryBuilder qb = multiMatchQuery(searchParameters, "*").type(MOST_FIELDS);
idSearchSourceBuilder.query(qb);
idSearchRequest.source(idSearchSourceBuilder);
SearchResponse searchResponse;
try {
searchResponse = esClient.search(idSearchRequest, RequestOptions.DEFAULT);
SearchHit[] searchHits = searchResponse.getHits().getHits();
for (SearchHit searchHit : searchHits) {
Recipient searchHitRecipient = modelMapper().readValue(searchHit.getSourceAsString(), Recipient.class);
searchRecipients.add(searchHitRecipient);
}
} catch (IOException e) {
log.error(e.getMessage());
}
And if I imply this code I get such request:
POST test/_search
{
"multi_match" : {
"query" : "1 254898",
"fields" : [
"*^1.0"
],
"type" : "most_fields",
"operator" : "OR",
"slop" : 0,
"prefix_length" : 0,
"max_expansions" : 50,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"fuzzy_transpositions" : true,
"boost" : 1.0
}
}
I got such error:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "Unknown key for a START_OBJECT in [multi_match].",
"line": 2,
"col": 19
}
],
"type": "parsing_exception",
"reason": "Unknown key for a START_OBJECT in [multi_match].",
"line": 2,
"col": 19
},
"status": 400
}
After changing query to:
POST test/_search
{
"query": {
"multi_match" : {
"query" : "1 254898",
"fields" : [
"recipient.document.number^1.0",
"recipient.document.type^1.0"
],
"type" : "most_fields",
"operator" : "OR",
"slop" : 0,
"prefix_length" : 0,
"max_expansions" : 50,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"fuzzy_transpositions" : true,
"boost" : 1.0
}
}
}
I get such error:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: {\n \"multi_match\" : {\n \"query\" : \"1 254898\",\n \"fields\" : [\n \"*^1.0\"\n ],\n \"type\" : \"most_fields\",\n \"operator\" : \"OR\",\n \"slop\" : 0,\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"zero_terms_query\" : \"NONE\",\n \"auto_generate_synonyms_phrase_query\" : true,\n \"fuzzy_transpositions\" : true,\n \"boost\" : 1.0\n }\n}",
"index_uuid": "kZAjfQWHQ6SkNIETBxhfOA",
"index": "portal-smm-recipient"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "portal-smm-recipient",
"node": "JEwfXRPHQSWjPn4L4U6AVQ",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: {\n \"multi_match\" : {\n \"query\" : \"1 254898\",\n \"fields\" : [\n \"*^1.0\"\n ],\n \"type\" : \"most_fields\",\n \"operator\" : \"OR\",\n \"slop\" : 0,\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"zero_terms_query\" : \"NONE\",\n \"auto_generate_synonyms_phrase_query\" : true,\n \"fuzzy_transpositions\" : true,\n \"boost\" : 1.0\n }\n}",
"index_uuid": "kZAjfQWHQ6SkNIETBxhfOA",
"index": "portal-smm-recipient",
"caused_by": {
"type": "number_format_exception",
"reason": "For input string: \"1 254898\""
}
}
}
]
},
"status": 400
}
What I'm doing wrong?