elastic_client
elastic_client copied to clipboard
Issues obtaining only suggestions
First problem:
There is no way to retrieve only suggestions since the 'query' field is mandatory. Unnecessary data is returned, consuming unnecessary network resources.
\elastic_client-0.3.15\lib\src\_client.dart
at line 300
final map = {
if (source != null) '_source': source,
if (fields != null) 'fields': fields,
'query': query ?? Query.matchAll(), // hereeeeee
if (offset != null) 'from': offset,
if (limit != null) 'size': limit,
if (suggest != null) 'suggest': suggest,
if (sort != null) 'sort': sort,
if (aggregations != null) 'aggregations': aggregations,
if (highlight != null) 'highlight': highlight.toMap(),
if (trackTotalHits != null) 'track_total_hits': trackTotalHits,
if (size != null) 'size': size,
if (minScore != null) 'min_score': minScore,
if (knn != null) 'knn': knn,
};
Second Issue:
The mapping with the response JSON does not match as illustrated below.
Elasticsearch Response Version: 8.11.4
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"suggest": {
"suggestion": [
{
"text": "123",
"offset": 0,
"length": 3,
"options": [
{
"text": "123",
"_index": "suggestions",
"_id": "123",
"_score": 30,
"_source": {
"name": "123",
"suggest": {
"input": [
"123"
],
"weight": 30
}
}
}
]
}
]
}
}
Mapping of the file \elastic_client-0.3.15\lib\src\_client.dart
at line 331
return SuggestHitOption(
m['text'] as String,
m['score'] as double, // <--------hereee
freq: (m['freq'] ?? -1) as int,
highlighted: m['highlighted'] as String,
);