Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues obtaining only suggestions #71

Open
jovanygonzalez opened this issue Jan 16, 2024 · 0 comments
Open

Issues obtaining only suggestions #71

jovanygonzalez opened this issue Jan 16, 2024 · 0 comments

Comments

@jovanygonzalez
Copy link

jovanygonzalez commented Jan 16, 2024

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,
          );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant