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:
parent
08e196910f
commit
674dddca8a
1 changed files with 40 additions and 1 deletions
|
@ -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,
|
||||
},
|
||||
}, */
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue