request resolver with es...trying to limit filter results
I have a query like this...
{
"version":"2017-02-28",
"operation":"GET",
"path":"/articlesnew1/json/_search",
"params":{
"body": {
"size": 50,
"query": {
"bool": {
"should" : [
{
"exists" : {
"field" : "field_categories.__target_path"
}
},
{
"exists" : {
"field" : "field_plays.__target_path"
}
},
{
"terms" : {
"field_categories.__target_path" : ["he/taxonomy_term/categories/837","he/taxonomy_term/categories/840","he/taxonomy_term/categories/841","he/taxonomy_term/categories/842""]
}
},
{
"terms" : {
"field_plays.__target_path" : ["he/taxonomy_term/plays/757","he/taxonomy_term/plays/758""]
}
}
],
"must_not": [
{
"term": {
"field_exclude_from_syndication.value": 1
}
}
],
"filter": [
{
"terms": {
"entity.bundle" : ["he_activity_highlight","he_company","he_event","he_exclusive","he_industry_voice","he_new_financing","he_news","he_opinion","he_person","he_publication","he_transaction","he_under_40","he_whos_who"]
}
},
{
"range" : {
"entity.changed.timestamp" : {
"gte": "${context.arguments.from}",
"lte": "${context.arguments.to}"
}
}
}
]
}
}
}
}
}
But I do not want results where either "field_categories.target_path" or "field_plays.target_path" are not present and matching one of the values. But I am still getting results where both are empty like this...
========================================
"field_categories": [],
"field_plays": [],
========================================
The expected results might look like this...
"field_categories": [{
"__target_path": "he/taxonomy_term/categories/850"
}],
...or this...
"field_plays": [{
"__target_path": "he/taxonomy_term/plays/772"
}],
ideas?
Edited by: cjokinen on Jun 10, 2019 2:30 PM
Edited by: cjokinen on Jun 10, 2019 2:31 PM
Edited by: cjokinen on Jun 10, 2019 2:32 PM
UPDATE: I changed my code to what is below, but it is too restrictive and only returns records that have both the category and play flelds. I need it to return records if both or either field exist.
{
"version":"2017-02-28",
"operation":"GET",
"path":"/articlesnew1/json/_search",
"params":{
"body": {
"size": 50,
"query": {
"bool": {
"should" : [
{
"terms" : {
"field_categories.__target_path" : ["he/taxonomy_term/categories/837","he/taxonomy_term/categories/840","he/taxonomy_term/categories/841","he/taxonomy_term/categories/842"]
}
},
{
"terms" : {
"field_plays.__target_path" : ["he/taxonomy_term/plays/757","he/taxonomy_term/plays/758","he/taxonomy_term/plays/759","he/taxonomy_term/plays/761","he/taxonomy_term/plays/762","he/taxonomy_term/plays/763","he/taxonomy_term/plays/764"]
}
}
],
"must_not": [
{
"term": {
"field_exclude_from_syndication.value": 1
}
}
],
"must": [
{
"bool": {
"should" : [{
"exists": {
"field" : "field_categories.__target_path"
},
"exists": {
"field" : "field_plays.__target_path"
}
}]
}
}
],
"filter": [
{
"terms": {
"entity.bundle" : ["he_activity_highlight","he_company","he_event","he_exclusive","he_industry_voice","he_new_financing","he_news","he_opinion","he_person","he_publication","he_transaction","he_under_40","he_whos_who"]
}
},
{
"range" : {
"entity.changed.timestamp" : {
"gte": "${context.arguments.from}",
"lte": "${context.arguments.to}"
}
}
}
]
}
}
}
}
}
Ideas?
Edited by: cjokinen on Jun 11, 2019 9:33 AM
Edited by: cjokinen on Jun 11, 2019 9:34 AM
I found the answer in that I missed some curly braces inside of the must section....
{
"version":"2017-02-28",
"operation":"GET",
"path":"/articlesnew1/json/_search",
"params":{
"body": {
"size": 50,
"query": {
"bool": {
"should" : [
{
"terms" : {
"field_categories.__target_path" : ["he/taxonomy_term/categories/837","he/taxonomy_term/categories/840","he/taxonomy_term/categories/841","he/taxonomy_term/categories/842"]
}
},
{
"terms" : {
"field_plays.__target_path" : ["he/taxonomy_term/plays/757","he/taxonomy_term/plays/758","he/taxonomy_term/plays/759","he/taxonomy_term/plays/761","he/taxonomy_term/plays/762","he/taxonomy_term/plays/763","he/taxonomy_term/plays/764"]
}
}
],
"must_not": [
{
"term": {
"field_exclude_from_syndication.value": 1
}
}
],
"must": [
{
"bool": {
"should" : [{
"exists": {
"field" : "field_categories.__target_path"
}
},
{
"exists": {
"field" : "field_plays.__target_path"
}
}]
}
}
],
"filter": [
{
"terms": {
"entity.bundle" : ["he_activity_highlight","he_company","he_event","he_exclusive"]
}
},
{
"range" : {
"entity.changed.timestamp" : {
"gte": "${context.arguments.from}",
"lte": "${context.arguments.to}"
}
}
}
]
}
}
}
}
}
Edited by: cjokinen on Jun 11, 2019 1:21 PM
Relevant questions
GraphQL DynamoDb filter List field
asked 2 years agoAWS Route53 Resolver Query Log Config - Terraform - error [RSLVR-00200]
asked 2 months agoNested query Cloudwatch Log Insights
asked 3 years agoDAX not working with lastEvaluatedKey
asked 5 months agorequest resolver with es...trying to limit filter results
asked 3 years agoHow do I compose a BULK request to OpenSearch via AppSync resolver mapping templates?
asked a month agoAWS scan and query not working as intended
asked 14 days agoHow to Filter by Query on Nested Fields in AWS AppSync
asked 3 years agoHow do I use a schema fields default value in a template?
asked 3 years agoFilters, IN comparison operator, toDynamoDBFilterExpression()
asked 3 years ago