Skip to content

Commit

Permalink
Use nested queries in taxa/search.
Browse files Browse the repository at this point in the history
  • Loading branch information
kueda committed Feb 6, 2018
1 parent ebd6558 commit 3ebcbe5
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions lib/controllers/v1/taxa_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,32 @@ TaxaController.search = function( req, callback ) {
// add highlighting to detect which taxon name matched the search
searchReq.query.highlight = { fields: { "names.name_autocomplete": { } } };
if( util.is_ja( params.q ) ) {
filters.push({ multi_match: {
query: params.q,
fields: [ "names.name_autocomplete_ja^10", "names.name_autocomplete" ]
}});
filters.push( {
nested: {
path: "names",
query: {
multi_match: {
query: params.q,
fields: [ "names.name_autocomplete_ja^10", "names.name_autocomplete" ]
}
}
}
} );
searchReq.query.highlight.fields[ "names.name_autocomplete_ja" ] = { };
} else {
filters.push({ match: { "names.name_autocomplete": {
query: params.q, operator: "and"
}}});
filters.push( {
nested: {
path: "names",
query: {
match: {
"names.name_autocomplete": {
query: params.q,
operator: "and"
}
}
}
}
} );
}
}
// default to sort ascending
Expand Down

0 comments on commit 3ebcbe5

Please sign in to comment.