unable to extract the group under gitlab through API call - bash

I am using shell script to list out all the group under GITLAB. its huge number of list how can we find out all groups, its more than 30 seems. and iterate through it to find out ID of group?
if any other solution please suggest to list all the group ID.
grouplist=$(curl --header "PRIVATE-TOKEN: $1" "https://gitlab.com/api/v4/groups?per_page=100&page=30" | jq -r '.[].id')

The gitlab documentation says:
When accessed without authentication, this endpoint also supports keyset pagination:
When requesting consecutive pages of results, we recommend you use keyset pagination.
Beyond a specific offset limit (specified by max offset allowed by the REST API for offset-based pagination), offset pagination is unavailable.
See https://docs.gitlab.com/ee/api/index.html#keyset-based-pagination for more details about keyset pagination. You will have to call curl repeatedly until there are no more results:
When the end of the collection is reached and there are no additional records to retrieve, the Link header is absent and the resulting array is empty. We recommend using only the given link to retrieve the next page instead of building your own URL.
The retrieved JSON documents can then can be fed to jq.

Related

Need to Get data for an index for a timeframe using curl or using url

I need to Get data for an index for a timeframe using curl or using url.
I was able to get the data using below created url
http://localhost:9200/index_name/_search?size=10&q="* AND severity:major|critical"
but I am not sure where to provide the timeframe for example i only want data from last 15minutes.
Can anyone help me with a way it can be done
You can do it like this by adding #timestamp:[now-15m TO now] to your query:
http://localhost:9200/index_name/_search?size=10&q="* AND severity:major|critical AND #timestamp:[now-15m TO now]"

Is there a way to limit the keys returned on an object in a query?

I have a user object with dozens of keys on it. Is it possible to give a query some parameters such that only certain fields on the user come back and I have to fetch the rest?
To limit the keys in the returned result set you can use 'keys' parameter in rest api.
Sample GET request:
https://demodomain/parse/classes/ClassName?keys=key1,key2,key3
For more:
https://docs.parseplatform.org/rest/guide/#query-constraints

Couchdb get the changed document with each change notification

I'm quite sure that I want to be notified with the inserted document by each insertion in the couch db.
something like this:
http://localhost:5058/db-name/_chnages/_view/inserted-document
And I like the response to be something like the following:
{
"id":"0552065465",
"name":"james"
.
.
.
}
Reconnecting to the database for giving the actual document by each notification can cause performance issues.
Can I define a view that return the actual document by each change?
There are 3 possible way to define if a document was just added:
You add a status field to your document with a specific status for new documents.
If the revision starts with a 1- but it's not 100% accurate according to this if you do replication.
In the changes response, check if the number of revision of the document is equal to one. If so, it means it was just added(best solution IMO)
If you want to query the _changes endpoint and directly get the newly inserted documents, you can use the approach #1 and use a filter function that only returns documents with status="new".
Otherwise, you should go with approach #3 and filter the _changes responses locally. Eg: your application would receive all changes and only handle documents with revisions array count equal to 1.
And as you mentioned, you want to receive the document, not only the _id and the _rev. To do so, you can simply add the query parameter: include_docs=true

Elastic Search - Fetch only certain field across all indexes

I have hundreds of indexes and I want to fetch only a given field from every record under these indexes. I can do the following
curl -XGET 'http://localhost:9200/cms-2016-03-30/job/_search?pretty=true&field=CMSDataset'
This unfortunately returns a lot of things I don't want and also doesn't give me all the records (~10^6).
Also, there are many cms-* style indexes, and I want to parse through all of them and get only this field. How do I do this?
You need to use source filtering instead of fields (which is deprecated)
curl -XGET 'http://localhost:9200/cms-2016-03-30/job/_search?pretty=true&_source=CMSDataset'
^
|
change this
From the official documentation:
The fields parameter is about fields that are explicitly marked as stored in the mapping, which is off by default and generally not recommended. Use source filtering instead to select subsets of the original source document to be returned.
UPDATE
You can use the size parameter (e.g. 100) in order to return more records (by default it's 10) and then simply use * as the index name:
curl -XGET 'http://localhost:9200/*/_search?pretty=true&size=100&_source=CMSDataset'

google place api Incorrect Results

Hi I have a problem with displaying the results of a google place api
When I write nightclub Google search I get results that match my search
But when I search through google place api I get the results is not so correct as Bookstore, apartments for rent and other results not so related
The URL looks like this
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=32.0768214,34.8147987&radius=5000&keyword=Nightclub&sensor=true&language=en&key=MyKey
Thank you!
As the docs state:
keyword — A term to be matched against all content that Google has indexed for this Place, including but not limited to name, type, and address, as well as customer reviews and other third-party content.
So that filter isn't going to be quite as specific as you would like. If you only want to get night clubs, you can use the types param with a value of night_club. See Supported Place Types for all of the other possible values.

Resources