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

Spellchecker : Fix multi index by alias error #3199

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ private function getTermVectors(RequestInterface $request)

$docs = [];

// Compute the mtermvector query on all shards to ensure exhaustive results.
foreach (range(0, $shards - 1) as $shard) {
$doc['routing'] = sprintf("[%s][%s]", $request->getIndex(), $shard);
$docs[] = $doc;
// Compute the mtermvector query on all indices.
foreach (array_keys($stats['indices']) as $indexName) {
// Compute the mtermvector query on all shards to ensure exhaustive results.
foreach (range(0, $shards - 1) as $shard) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have 2 indices having the same alias, and each of these indices having 3 shards.

What do you have in $shards at this step ? 6 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but you don't have the information of which shard is assigned to which index

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm so if I understand properly, if we have :

  • index "aaaa" with 3 shards
  • index "bbbb" with 3 shards
  • they both share the "product" alias

In the end, in routing, we'll have :

  • [aaaa][0], [aaaa][1], [aaaa][2], [aaaa][3], [aaaa][4], [aaaa][5]
  • [bbbb][0], [bbbb][1], [bbbb][2], [bbbb][3], [bbbb][4], [bbbb][5]

And it will work even if shards 3 4 and 5 does not exist for these index ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes your example is correct and it seems to work properly even if the shard doesn't exist

$doc['_index'] = $indexName;
$doc['routing'] = sprintf("[%s][%s]", $indexName, $shard);
$docs[] = $doc;
}
}

$mtermVectorsQuery['body'] = ['docs' => $docs];
Expand Down
Loading