Skip to content

Commit f271ede

Browse files
committed
work around ESXM inflating using the index from data
MetaCPAN::Model is configured to use indexes that may be aliases on the actual servers. It doesn't know about the index that the server is using. When inflating, it should use the index it has been configured with, not the one taken from the data.
1 parent 141e045 commit f271ede

File tree

1 file changed

+13
-0
lines changed
  • lib/ElasticSearchX/Model/Document

1 file changed

+13
-0
lines changed

lib/ElasticSearchX/Model/Document/Set.pm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,17 @@ my $get = \&get;
4444
goto &$get;
4545
};
4646

47+
# ESXM will try to inflate based on the index/type stored in the result. We
48+
# are using aliases, and ESXM doesn't know about the actual index that the
49+
# docs are stored in. Instead, allow it to use the configured index/type for
50+
# this doc set.
51+
my $inflate_result = \&inflate_result;
52+
*inflate_result = sub {
53+
my ( $self, $res ) = @_;
54+
my $new_res = { %$res };
55+
delete $new_res->{_index};
56+
delete $new_res->{_type};
57+
$self->$inflate_result($new_res);
58+
};
59+
4760
1;

0 commit comments

Comments
 (0)