Opensearch with term query returns no aggregations - node.js

I am trying to query data using the term aggregation in AWS OpenSearch to get the group by the result using 1 field. The query below working in their Dev tools successfully as expected. Attaching a screenshot below.
But when I try to do this same in the query in Node.js it's not giving a bucket array result. I search a lot but I found nothing different than my code. I have attached a screenshot and the result below. In the screenshot, I am able to see 16 as the total result but not a bucket result. Please help me to figure out what I am doing wrong here.

Related

unable to fetch result in azure cognitive search when using searchMode=all

I am using semantic search in azs, api version is 21-04-30, analyers i have selected is engish microsoft while creating index.
When i am typing any question in query string with searchMode=all, i am getting nothing as a result, when i am typing searchMode=any, then it is giving me result but not accurate. Can anyone help me?
(https://i.stack.imgur.com/Lm2IC.png)
Please check this image
I am writing query in question form with all search mode, but not getting expected result. if i am removing query keywords such as what , it is giving me result but not while framing question. Please help.

Getting array of data using elemMatch is not working

I want to get particular object in array. My database structure is shown in below image
In this i am trying to get particular object like this
db.users.find({article:{$elemMatch:{articleid:"WMCA268937"}}})
but nothing is getting, someone please help.

sails blueprints query in url not working

I have various GET http calls to my api with the following format:
/api/posts?userId=3
However, it is not filtering posts by its userId column, and just returns all posts, regardless of the posts' userId.
This syntax has worked in past projects I've had also, and is documented here. (The example they give is GET /purchase?amount=99.99).
Questions I've seen do not address the query language via defaults routes in this way, so I'm having trouble finding help. Any guesses on what could be going wrong?
UPDATE:
What does work as expected
req.query is getting set and read by policies (eg, ?userId=3 is found by req.param("userId"))
/api/posts?userId=3&populate=userId populates the userId field, (but still returns all posts for all users)
filtering by primary key (eg ?id=5) filters and returns only one record as expected
When working in the api, or in sails console, (eg Posts.find({userId: 3})) works
What does not work as expected
filtering by foreign keys (eg ?userId=6)
filtering by non-foreign keys (eg ?name=test)
filtering using where (eg &where={"userId":1})
It turns out I was adding a "where" clause to every query in a policy (eg, "where: {"status": "active"}}). Having a "where" in the query string automatically overrides the other params, and so nothing else was getting seen. (To be precise, if you have a where clause, other criteria never get seen)
For some reason, the "where" was also not working to set the search criteria for sails 0.12.13, so I ended up hacking the parseCriteria function actionUtils in sails and using the one they have for v.1 and that worked for me.
Hope that helps anyone in the future

Azure NextMarker

I have created a container in Azure called files. It has 3 images and 2 txt files.
https://attosolstorage.blob.core.windows.net/files?comp=list
With the URL listed above, NextMarker will be empty. If I use the following URL..
https://attosolstorage.blob.core.windows.net/files?comp=list&maxresults=1
It shows the NextMarker field populated, and what I understand from this article is that using NextMarker as a QueryString should give me the 2nd object. However, this URL gives the same output as the previous one.
https://attosolstorage.blob.core.windows.net/files?comp=list&maxresults=1&nextmarker=1!16!aW1nL3JlZC5qcGc-
What am I missing?
Actually the query string parameter is marker and not nextmarker (https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx) :).
So if you try: https://attosolstorage.blob.core.windows.net/files?comp=list&maxresults=1&marker=1!16!aW1nL3JlZC5qcGc-, things should work just fine.

GmailAPI: How can I get the next page of results for a certain query?

I have a certain query that I am using to get results that correspond to a particular search:
response = gmail_service.users().messages().list(userId=user_id, q='from:"digital-no-reply#amazon.com"', pageToken='').execute()
To get the next page of results, is this the right query:
response = gmail_service.users().messages().list(userId=user_id, q='from:"digital-no-reply#amazon.com"', pageToken=next_page_token).execute()
I tried not giving the query param, thinking that the next_page_token should contain a reference to the query that generated the previous page, but the results I got did not come from the query parameter. Hence wondering what is the correct way of getting all pages of results corresponding to the query?
Your suspicion is correct. Just supply the same query on your next page fetch and repeat until there is no pageToken in the response. Then you know you have gotten all the results of that particular query.

Resources