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',
|
index : 'claims',
|
||||||
_source: ['name', 'value', 'claimId'],
|
_source: ['name', 'value', 'claimId'],
|
||||||
body : {
|
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': {
|
'query': {
|
||||||
'bool': {
|
'bool': {
|
||||||
'must': {
|
'must': {
|
||||||
|
@ -43,7 +82,7 @@ function getResults (input) {
|
||||||
},
|
},
|
||||||
size: input.size,
|
size: input.size,
|
||||||
from: input.from,
|
from: input.from,
|
||||||
},
|
}, */
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue