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

Results of fuzzy suggestion are in reverse order #93

Open
markrsocialnative opened this issue Nov 5, 2020 · 0 comments
Open

Results of fuzzy suggestion are in reverse order #93

markrsocialnative opened this issue Nov 5, 2020 · 0 comments

Comments

@markrsocialnative
Copy link
Contributor

markrsocialnative commented Nov 5, 2020

Created because of this.

The library seems to reverse the order of the response from elastic search when generating a list of fuzzy suggestions.

For example

const field = 'tags';
const results = composer.suggestions.fuzzy.fieldSearches[field];
// 'results' is something like this. 
// Notice how suggestion: 'food' is the last entry. 
// In the network request, it is the first entry.
// [
//     ...other results before,
//     {
//         suggestion: 'Food & Bev',
//         count: 2995
//     },
//     {
//         suggestion: 'food',
//         count: 3530
//     }
// ];

With a corresponding network response looking something like this:

{
  "took": 16,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 4063,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "tags__fuzzy_suggestion": {
      "doc_count_error_upper_bound": 138,
      "sum_other_doc_count": 11949,
      "buckets": [
        {
          "key": "food",
          "doc_count": 3530
        },
        {
          "key": "Food & Bev",
          "doc_count": 2995
        },
        // ... Other entries
      ]
    }
  }
}

The consequence is that the result must be "un" reversed by elastic composer users.

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