Skip to content

Commit d4e04c2

Browse files
committed
suggest: ES syntax update for newer version
1 parent 97fee03 commit d4e04c2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/suggest.pl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,34 @@ ($range)
6464

6565
my $files = $es->scroll(
6666
scroll => '5m',
67-
fields => [qw< id documentation >],
6867
body => {
6968
query => {
7069
bool => {
7170
must => [
7271
{ exists => { field => "documentation" } }, $range
7372
],
7473
}
75-
}
74+
},
75+
_source => [qw< id documentation >],
76+
size => 500,
77+
sort => '_doc',
7678
},
7779
);
7880

7981
my $bulk = $es->bulk( timeout => '5m' );
8082

8183
while ( my $file = $files->next ) {
82-
my $documentation = $file->{fields}{documentation}[0];
84+
my $documentation = $file->{_source}{documentation};
8385
my $weight = 1000 - length($documentation);
8486
$weight = 0 if $weight < 0;
8587

8688
$bulk->update( {
87-
id => $file->{fields}{id}[0],
89+
id => $file->{_id},
8890
doc => {
8991
suggest => {
9092
input => [$documentation],
91-
payload => { doc_name => $documentation },
9293
weight => $weight,
93-
}
94+
},
9495
},
9596
} );
9697
}

0 commit comments

Comments
 (0)