Added more 1..n term based breakdown of query and concatenation to assist with partial matching. Added a massive weight so these likely scenario's or "intended" scenarios pass.
This commit is contained in:
parent
127155ef16
commit
7e99d9eace
1 changed files with 40 additions and 10 deletions
|
@ -84,16 +84,46 @@ function getResults (input) {
|
||||||
|
|
||||||
const splitName = () => {
|
const splitName = () => {
|
||||||
let queries = [];
|
let queries = [];
|
||||||
|
let conCatTerm = '';
|
||||||
|
let phraseTerm = '';
|
||||||
escapedQuery.split(' ').forEach((term) => {
|
escapedQuery.split(' ').forEach((term) => {
|
||||||
queries.push({ // Contains search term
|
phraseTerm = phraseTerm + ' ' + term;
|
||||||
'query_string': {
|
conCatTerm = conCatTerm + term;
|
||||||
'query' : `*${term}*`,
|
queries.push(
|
||||||
'fields': [
|
{ // Contains an individual search term
|
||||||
'name',
|
'query_string': {
|
||||||
],
|
'query' : `*${term}*`,
|
||||||
'boost': 3,
|
'fields': [
|
||||||
|
'name',
|
||||||
|
],
|
||||||
|
'boost': 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
{ // Contains 1..n of the terms as a phrase
|
||||||
|
'query_string': {
|
||||||
|
'query' : `*${phraseTerm}*`,
|
||||||
|
'fields': [
|
||||||
|
'name',
|
||||||
|
],
|
||||||
|
'boost': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ // Contains 1..n of the terms together
|
||||||
|
'query_string': {
|
||||||
|
'query' : `*${conCatTerm}*`,
|
||||||
|
'fields': [
|
||||||
|
'name',
|
||||||
|
],
|
||||||
|
'boost': 300,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'prefix': { 'name': { 'value': '@' + escapedQuery, 'boost': 10 } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'prefix': { 'name': { 'value': escapedQuery, 'boost': 10 } },
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
return queries;
|
return queries;
|
||||||
};
|
};
|
||||||
|
@ -126,7 +156,7 @@ function getResults (input) {
|
||||||
const matTextName = { // Match search text - Name
|
const matTextName = { // Match search text - Name
|
||||||
'match': {
|
'match': {
|
||||||
'name': {
|
'name': {
|
||||||
'query': washedQuery,
|
'query': escapedQuery,
|
||||||
'boost': 5,
|
'boost': 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -475,7 +505,7 @@ class LighthouseControllers {
|
||||||
let cResults = [];
|
let cResults = [];
|
||||||
for (let pResult of results) {
|
for (let pResult of results) {
|
||||||
var name = pResult._source.name;
|
var name = pResult._source.name;
|
||||||
if (name.indexOf(ctx.query.s.trim()) > -1 && name.indexOf('http') === -1) {
|
if (name.toString().indexOf(ctx.query.s.trim()) > -1 && name.toString().indexOf('http') === -1) {
|
||||||
cResults.push(name);
|
cResults.push(name);
|
||||||
}
|
}
|
||||||
if (pResult._source.value &&
|
if (pResult._source.value &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue