} else {
// Sort by match score by default.
- search.sort(new Sort('_score', 'asc'));
+ search.sort(new Sort('_score', 'desc'));
}
}
my @nodes;
for my $server (@{$self->nodes}) {
- push(@nodes, sprintf("%s://%s:%d%s",
- $server->proto, $server->host, $server->port, $server->path));
+ push(@nodes, {
+ scheme => $server->proto,
+ host => $server->host,
+ port => $server->port,
+ path => $server->path
+ });
}
- $logger->debug("ES connecting to nodes @nodes");
+ $logger->debug("ES connecting to ".scalar(@nodes)." nodes");
eval { $self->{es} = Search::Elasticsearch->new(nodes => \@nodes) };
if ($field->search_field eq 't') {
# Text search fields get an additional variety of indexes to
# support full text searching
-
+
$fields->{text} = {type => 'text'},
$fields->{text_folded} = {type => 'text', analyzer => 'folding'};
analyzer => $lang_analyzer
};
}
+
+ if ((my $boost = ($field->weight || 1)) > 1) {
+ $fields->{text}->{boost} = $boost;
+ $fields->{text_folded}->{boost} = $boost;
+ $fields->{"text_$_"}->{boost} = $boost
+ foreach $self->language_analyzers;
+ }
}
$def->{fields} = $fields if keys %$fields;
- # Apply field boost.
- $def->{boost} = $field->weight if ($field->weight || 1) > 1;
-
$logger->debug("ES adding field $field_name: ".
OpenSRF::Utils::JSON->perl2JSON($def));
# Title search AND subject search AND MARC tag=100 search
my $query = {
- _source => ['id', 'title|proper'] , # return only the ID field
+ _source => ['id', 'title|maintitle'] , # return only the ID field
from => 0,
size => 5,
- sort => [
- {'titlesort' => 'asc'},
- '_score'
- ],
+ sort => [{'_score' => 'desc'}],
query => {
bool => {
must => [{