updated search query for elasticsearch. value is stored as a nested object in the elastic document. Therefore to query fields at that level or lower, a nested query is required.

This commit is contained in:
Mark Beamer Jr 2018-03-08 22:09:48 -05:00
parent 08e196910f
commit 674dddca8a

View file

@ -26,6 +26,45 @@ function getResults (input) {
index : 'claims',
_source: ['name', 'value', 'claimId'],
body : {
'query': {
'bool': {
'should': [
{
'match': {
'name^100': '*' + input.s.trim() + '*',
},
},
{
'nested': { // Need nested query because value is a nested object on the elastic document
'path' : 'value',
'query': {
'bool': {
'should': [
{
'match': {
'value.stream.metadata.title': '*' + input.s.trim() + '*',
},
},
{
'match': {
'value.stream.metadata.author': '*' + input.s.trim() + '*',
},
},
{
'match': {
'value.stream.metadata.description': '*' + input.s.trim() + '*',
},
},
],
},
},
},
},
],
},
},
},
/* body : {
'query': {
'bool': {
'must': {
@ -43,7 +82,7 @@ function getResults (input) {
},
size: input.size,
from: input.from,
},
}, */
});
}