Merge pull request #53 from lbryio/search_updates
using ^n on a field is only valid syntax for lycene. This caused the …
This commit is contained in:
commit
14bfde88b9
1 changed files with 29 additions and 27 deletions
|
@ -18,7 +18,6 @@ const eclient = new elasticsearch.Client({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function getResults (input) {
|
function getResults (input) {
|
||||||
if (input.size === undefined) input.size = 10;
|
if (input.size === undefined) input.size = 10;
|
||||||
if (input.from === undefined) input.from = 0;
|
if (input.from === undefined) input.from = 0;
|
||||||
|
@ -31,7 +30,10 @@ function getResults (input) {
|
||||||
'should': [
|
'should': [
|
||||||
{
|
{
|
||||||
'match': {
|
'match': {
|
||||||
'name^100': '*' + input.s.trim() + '*',
|
'name': {
|
||||||
|
'query': '*' + input.s.trim() + '*',
|
||||||
|
'boost': 5,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -89,12 +91,12 @@ function getResults (input) {
|
||||||
function getIndex () {
|
function getIndex () {
|
||||||
// ideally, data is inserted into elastic search with an index that helps us query it faster/better results
|
// ideally, data is inserted into elastic search with an index that helps us query it faster/better results
|
||||||
// A simple start is to default queries to be within the n months, and to make a new index each month.
|
// A simple start is to default queries to be within the n months, and to make a new index each month.
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRoutingKey () {
|
function getRoutingKey () {
|
||||||
// This is the most important field for performance. Being able to route the queries ahead of time can make typedowns insanely good.
|
// This is the most important field for performance. Being able to route the queries ahead of time can make typedowns insanely good.
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAutoCompleteQuery (query) {
|
function getAutoCompleteQuery (query) {
|
||||||
|
@ -108,16 +110,16 @@ function getAutoCompleteQuery(query) {
|
||||||
'name',
|
'name',
|
||||||
'value.stream.metadata.author',
|
'value.stream.metadata.author',
|
||||||
'value.stream.metadata.title',
|
'value.stream.metadata.title',
|
||||||
'value.stream.metadata.description'
|
'value.stream.metadata.description',
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFilter (query) {
|
function getFilter (query) {
|
||||||
// this is the best place for putting things like filtering on the type of content
|
// this is the best place for putting things like filtering on the type of content
|
||||||
// Perhaps we can add search param that will filter on how people have categorized / tagged their content
|
// Perhaps we can add search param that will filter on how people have categorized / tagged their content
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAutoComplete (query) {
|
function getAutoComplete (query) {
|
||||||
|
@ -131,9 +133,9 @@ function getAutoComplete(query) {
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
must : getAutoCompleteQuery(query),
|
must : getAutoCompleteQuery(query),
|
||||||
filter: getFilter(query)
|
filter: getFilter(query),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
size: query.size,
|
size: query.size,
|
||||||
from: query.from,
|
from: query.from,
|
||||||
|
@ -191,7 +193,7 @@ class LighthouseControllers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var clean = new Array();
|
var clean = [];
|
||||||
for (var i = 0; i < cResults.length; i++) {
|
for (var i = 0; i < cResults.length; i++) {
|
||||||
if (cResults[i] && cResults[i].length > 3 && clean.indexOf(cResults[i]) === -1) {
|
if (cResults[i] && cResults[i].length > 3 && clean.indexOf(cResults[i]) === -1) {
|
||||||
clean.push(cResults[i]);
|
clean.push(cResults[i]);
|
||||||
|
|
Loading…
Reference in a new issue