Some examples:
harry potter
-title|maintitle.text\\*:piano
+title|proper.text\\*:piano
author.text\\*:GrandPré
au:((johann brahms) OR (wolfgang mozart))
su:history
next unless $query_string;
my $query = {
- _source => ['id', 'title|maintitle'] , # return only a few fields
+ _source => ['id', 'title|proper', 'author|first_author'] , # return only a few fields
from => 0,
size => 10,
sort => [{'_score' => 'desc'}],
# Search the base keyword text index by default.
default_field => 'keyword.text'
}
+ },
+ # Request highligh data for title/author text fields.
+ # See below for logging highlight response data.
+ highlight => {
+ # Pre/Post tags modified to match stock Evergreen.
+ pre_tags => '<b class="oils_SH">',
+ post_tags => '</b>',
+ fields => {
+ 'title*.text' => {},
+ 'author*.text' => {}
+ }
}
};
for my $hit (@{$results->{hits}->{hits}}) {
printf("Record: %-8d | Score: %-11f | Title: %s\n",
$hit->{_id}, $hit->{_score},
- ($hit->{_source}->{'title|maintitle'} || '')
+ ($hit->{_source}->{'title|proper'} || '')
);
+
+# Uncomment to log highlighted field data.
+# for my $hl (keys %{$hit->{highlight}}) {
+# my @values = @{$hit->{highlight}->{$hl}};
+# print "\tHighlight: $hl => @values\n";
+# }
}
}