Merge pull request #83 from lbryio/revert-82-revert-81-controlling_weight

Revert "Revert "Updated search query""
This commit is contained in:
filipnyquist 2018-06-23 18:23:24 +02:00 committed by GitHub
commit d33c820eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,124 +41,136 @@ function getResults (input) {
'query': {
'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,
'bid_state': {
// Controlling claims should get higher placement in search results.
'query': 'Controlling',
'boost': 20,
},
},
},
{ // 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,
},
},
},
],
'function_score': {
'script_score': {
'script': { // 100 LBC adds 1 point to the score
'source': "0.00000001 * doc['effective_amount'].value",
},
},
},
},
],
'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,
from: input.from,
},
/* body : {
'query': {
'bool': {
'must': {
'query_string': {
'query' : '*' + input.s.trim() + '*',
'fields': [
'name',
'value.stream.metadata.author',
'value.stream.metadata.title',
'value.stream.metadata.description',
],
},
},
},
sort: {
_score: 'desc',
},
}, */
},
});
}