Revert "Revert "Updated search query""
This commit is contained in:
parent
e7d46c8082
commit
0557855fab
1 changed files with 115 additions and 103 deletions
|
@ -41,124 +41,136 @@ function getResults (input) {
|
||||||
'query': {
|
'query': {
|
||||||
'bool': {
|
'bool': {
|
||||||
'should': [
|
'should': [
|
||||||
{ // Match search text as phrase - Name
|
{
|
||||||
'match_phrase': {
|
|
||||||
'name': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 10,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search text - Name
|
|
||||||
'match': {
|
'match': {
|
||||||
'name': {
|
'bid_state': {
|
||||||
'query': input.s.trim(),
|
// Controlling claims should get higher placement in search results.
|
||||||
'boost': 5,
|
'query': 'Controlling',
|
||||||
|
'boost': 20,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ // Contains search term - Name
|
|
||||||
'query_string': {
|
|
||||||
'query' : '*' + input.s.trim() + '*',
|
|
||||||
'fields': [
|
|
||||||
'name',
|
|
||||||
],
|
|
||||||
'boost': 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'nested': {
|
'function_score': {
|
||||||
'path' : 'value',
|
'script_score': {
|
||||||
'query': {
|
'script': { // 100 LBC adds 1 point to the score
|
||||||
'bool': {
|
'source': "0.00000001 * doc['effective_amount'].value",
|
||||||
'should': [
|
|
||||||
{ // Contains search term in Author, Title, Description
|
|
||||||
'query_string': {
|
|
||||||
'query' : '*' + input.s.trim() + '*',
|
|
||||||
'fields': [
|
|
||||||
'value.stream.metadata.author',
|
|
||||||
'value.stream.metadata.title',
|
|
||||||
'value.stream.metadata.description',
|
|
||||||
],
|
|
||||||
'boost': 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search term - Author
|
|
||||||
'match': {
|
|
||||||
'value.stream.metadata.author': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search text as phrase - Author
|
|
||||||
'match_phrase': {
|
|
||||||
'value.stream.metadata.author': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search term - Title
|
|
||||||
'match': {
|
|
||||||
'value.stream.metadata.title': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search text as phrase - Title
|
|
||||||
'match_phrase': {
|
|
||||||
'value.stream.metadata.title': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search term - Description
|
|
||||||
'match': {
|
|
||||||
'value.stream.metadata.description': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ // Match search text as phrase - Description
|
|
||||||
'match_phrase': {
|
|
||||||
'value.stream.metadata.description': {
|
|
||||||
'query': input.s.trim(),
|
|
||||||
'boost': 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'must': [
|
||||||
|
{
|
||||||
|
'bool': {
|
||||||
|
'should': [
|
||||||
|
{ // Match search text as phrase - Name
|
||||||
|
'match_phrase': {
|
||||||
|
'name': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search text - Name
|
||||||
|
'match': {
|
||||||
|
'name': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Contains search term - Name
|
||||||
|
'query_string': {
|
||||||
|
'query' : '*' + input.s.trim() + '*',
|
||||||
|
'fields': [
|
||||||
|
'name',
|
||||||
|
],
|
||||||
|
'boost': 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'nested': {
|
||||||
|
'path' : 'value',
|
||||||
|
'query': {
|
||||||
|
'bool': {
|
||||||
|
'should': [
|
||||||
|
{ // Contains search term in Author, Title, Description
|
||||||
|
'query_string': {
|
||||||
|
'query' : '*' + input.s.trim() + '*',
|
||||||
|
'fields': [
|
||||||
|
'value.stream.metadata.author',
|
||||||
|
'value.stream.metadata.title',
|
||||||
|
'value.stream.metadata.description',
|
||||||
|
],
|
||||||
|
'boost': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search term - Author
|
||||||
|
'match': {
|
||||||
|
'value.stream.metadata.author': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search text as phrase - Author
|
||||||
|
'match_phrase': {
|
||||||
|
'value.stream.metadata.author': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search term - Title
|
||||||
|
'match': {
|
||||||
|
'value.stream.metadata.title': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search text as phrase - Title
|
||||||
|
'match_phrase': {
|
||||||
|
'value.stream.metadata.title': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search term - Description
|
||||||
|
'match': {
|
||||||
|
'value.stream.metadata.description': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Match search text as phrase - Description
|
||||||
|
'match_phrase': {
|
||||||
|
'value.stream.metadata.description': {
|
||||||
|
'query': input.s.trim(),
|
||||||
|
'boost': 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
size: input.size,
|
size: input.size,
|
||||||
from: input.from,
|
from: input.from,
|
||||||
},
|
sort: {
|
||||||
/* body : {
|
_score: 'desc',
|
||||||
'query': {
|
|
||||||
'bool': {
|
|
||||||
'must': {
|
|
||||||
'query_string': {
|
|
||||||
'query' : '*' + input.s.trim() + '*',
|
|
||||||
'fields': [
|
|
||||||
'name',
|
|
||||||
'value.stream.metadata.author',
|
|
||||||
'value.stream.metadata.title',
|
|
||||||
'value.stream.metadata.description',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}, */
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue