Revert "Updated search query" #82

Merged
filipnyquist merged 1 commit from revert-81-controlling_weight into master 2018-06-21 18:25:46 +02:00

View file

@ -41,125 +41,99 @@ 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': {
'bid_state': { 'name': {
// Controlling claims should get higher placement in search results. 'query': input.s.trim(),
'query': 'Controlling', 'boost': 5,
'boost': 20,
}, },
}, },
}, },
{ { // Contains search term - Name
'function_score': { 'query_string': {
'script_score': { 'query' : '*' + input.s.trim() + '*',
'script': { // 100 LBC adds 1 point to the score 'fields': [
'source': "0.00000001 * doc['effective_amount'].value", 'name',
}, ],
}, 'boost': 3,
}, },
}, },
],
'must': [
{ {
'bool': { 'nested': {
'should': [ 'path' : 'value',
{ // Match search text as phrase - Name 'query': {
'match_phrase': { 'bool': {
'name': { 'should': [
'query': input.s.trim(), { // Contains search term in Author, Title, Description
'boost': 10, 'query_string': {
}, 'query' : '*' + input.s.trim() + '*',
}, 'fields': [
}, 'value.stream.metadata.author',
{ // Match search text - Name 'value.stream.metadata.title',
'match': { 'value.stream.metadata.description',
'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,
},
},
},
], ],
'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,
},
},
},
],
}, },
], },
}, },
}, },
], ],
@ -167,10 +141,24 @@ function getResults (input) {
}, },
size: input.size, size: input.size,
from: input.from, from: input.from,
sort: {
_score: 'desc',
},
}, },
/* body : {
'query': {
'bool': {
'must': {
'query_string': {
'query' : '*' + input.s.trim() + '*',
'fields': [
'name',
'value.stream.metadata.author',
'value.stream.metadata.title',
'value.stream.metadata.description',
],
},
},
},
},
}, */
}); });
} }