How to get catalog search results by keywords via Amazon SP API that like Amazon website search results? - amazon

First method "listCatalogItems" produces correct results but limits max 10 ASINs. And now this method is deprecated.
Other method "searchCatalogItems" produces INcorrect random results.

fyi listCatalogItems says it's deprecated but it still works

I am getting correct results when I use searchCatalogItems. Here is my postman call: https://sellingpartnerapi-na.amazon.com/catalog/2022-04-01/items?marketplaceIds=ATVPDKIKX0DER&keywords=samsung
and part of my results:
{
"numberOfResults": 54592886,
"pagination": {
"nextToken": "9HkIVcuuPmX_bm51o3-igBfN45pxW4Ru7ElIM6GCECYCuXJKzT26f-3Tfs1Ro3IhelNA74VxDMJwt_JvE7qiRh0loZTzTpEBWUbZ8HB0T4ttV8cFw4xYQ4RMUzdY_udbnvAHOHCcZcycn0nW8RotZh1l1vj7KQoFIa7pWiOPHyaYWP7sBE9Fg7cGN2wE0an5ePw96h6ZL7m6olRxFOcqTWNanEVRjipq"
},
...
"items": [
{
"asin": "B09YN4W5C1",
"summaries": [
{
"marketplaceId": "ATVPDKIKX0DER",
"adultProduct": false,
"autographed": false,
"brand": "SAMSUNG",
"itemClassification": "VARIATION_PARENT",
"itemName": "SAMSUNG Jet Bot Robot Vacuum Cleaner",
"manufacturer": "SAMSUNG",
"memorabilia": false,
"packageQuantity": 1,
"tradeInEligible": false,
"websiteDisplayGroup": "home_display_on_website",
"websiteDisplayGroupName": "Home"
}
]
},
{
"asin": "B01AQ6OWAG",
"summaries": [
{
"marketplaceId": "ATVPDKIKX0DER",
"adultProduct": false,
"autographed": false,
"brand": "SAMSUNG",
"browseClassification": {
"displayName": "Remote Controls",
"classificationId": "10967581"
},
"itemClassification": "BASE_PRODUCT",
"itemName": "SAMSUNG TV Remote Control BN59-01199F by Samsung",
"manufacturer": "Samsung",
"memorabilia": false,
"modelNumber": "BN59-01199F",
"packageQuantity": 1,
"partNumber": "BN59-01199F",
"tradeInEligible": false,
"websiteDisplayGroup": "ce_display_on_website",
"websiteDisplayGroupName": "CE"
}
]
},

Related

Google Speech API transcribe email

I'm having trouble transcribing email using Google Speech REST API. The best I can get is most of the email address, however Google Speech ignores "dot" and "dot com". For example first.last#gmail.com returns "First Last at gmail". If I say "period" instead of "dot" I at least get "First. Last at gmail." I'm using the following:
{
"config": {
"encoding": "MULAW",
"sampleRateHertz": 8000,
"languageCode": "en-US",
"maxAlternatives": 0,
"profanityFilter": true,
"enableWordTimeOffsets": false,
"model": "phone_call",
"useEnhanced": true
},
"audio": {
"content":"&&NameBase64&&"
}
}
I've tried add "dot" as a speech context with no changes. ".", ".com", "com", and "kom" also didn't change the results.
{
"config": {
"encoding": "MULAW",
"sampleRateHertz": 8000,
"languageCode": "en-US",
"maxAlternatives": 1,
"profanityFilter": true,
"enableWordTimeOffsets": false,
"model": "phone_call",
"useEnhanced": true,
"speechContexts": [{
"phrases": ["dot"],
}],
},
"audio": {
"content":"Base64Recording"
}
}
I've tried adding alphanumberic speech contexts and spelling it out but the results were pretty bad.
Any thoughts on how I can get "." or "dot" and "com" to show up in the transcription would be greatly appreciated.
Have you tried providing a boost value for the phrase? I'm facing the same issue and I noticed that increasing the boost value helped in identifying the word "dot".
Boost values are usually between 0 and 20, but applying anything above 10 helped in recognizing the "dot".
Here's an example:-
"config": {
"encoding": "MULAW",
"sampleRateHertz": 8000,
"languageCode": "en-US",
"maxAlternatives": 1,
"profanityFilter": true,
"enableWordTimeOffsets": false,
"model": "phone_call",
"useEnhanced": true,
"speechContexts": [{
"phrases": ["dot"],
"boots": 15.0
}],
},
"audio": {
"content":"Base64Recording"
}
}
You can also have multiple key value pairs in the context, each with different boost values. For example, this is what I use to detect email addresses:-
[{
phrases: ["$OOV_CLASS_ALPHANUMERIC_SEQUENCE"],
boost: 14.0
},
{
phrases: ["gmail.com","yahoo.com","aol.com","outlook.com"],
boost:5.0
},
{
phrases: ["com",".","c o m",".com","dotcom","dot com","dot","at","at the rate","#"],
boost: 10.0
},
{
phrases: ["org","io","dot org","dot io","gov","dot gov","net","dot net","co","dot co"],
boost:8.0
},
{
phrases: ["$OOV_CLASS_DIGIT_SEQUENCE","8","naught","z","zed","zee","zz","d","aa","ae","ee","oo","ii","ay","eh","ahh","ah","ze","dee",
"1","2","3","4","5","6","7","8","9","0","zero",],
boost: -20.0
}
]
Notice, the phrases with negative boost values will help weed out words that are often misunderstood.

Get a workable URL from Python Get request

I'm scraping a JS loaded website using requests. In order to do so, I go to inspect website, network console and look for the XHR calls to know where is the website calling for the data and how. Process would be as follows
Go to the link https://www.888sport.es/futbol/#/event/1006276426 in Chrome. Once that is loaded, you can click on many items with an unique ID. After doing so, a pop up window with information appears. In the XHR call I mentioned above you get a direct link to get this information as follows:
import requests
url='https://eu-offering.kambicdn.org/offering/v2018/888es/betoffer/outcome.json?lang=es_ES&market=ES&client_id=2&channel_id=1&ncid=1586874367958&id=2740660278'
#ncid is the date in timestamp format, and id is the unique id of the node clicked
response=requests.get(url=url,headers=headers)
Problem is, this isn't user friendly and require python. If I put this last url in the Chrome driver, I get the information but in plain text, and I can't interact with it. Is there any way to get a workable link from the request so that manually inserting it in a Chrome driver it loads that pop up window directly, as a regular website?
You've to make the requests as .json() so you receive a json dict, which you can access it with keys.
import requests
import json
def main(url):
r = requests.get(url).json()
print(r.keys())
hview = json.dumps(r, indent=4)
print(hview) # here to see it in nice view.
main("https://eu-offering.kambicdn.org/offering/v2018/888es/betoffer/outcome.json?lang=es_ES&market=ES&client_id=2&channel_id=1&ncid=1586874367958&id=2740660278")
Output:
dict_keys(['betOffers', 'events', 'prePacks'])
{
"betOffers": [
{
"id": 2210856430,
"closed": "2020-04-17T14:30:00Z",
"criterion": {
"id": 1001159858,
"label": "Final del partido",
"englishLabel": "Full Time",
"order": [],
"occurrenceType": "GOALS",
"lifetime": "FULL_TIME"
},
"betOfferType": {
"id": 2,
"name": "Partido",
"englishName": "Match"
},
"eventId": 1006276426,
"outcomes": [
{
"id": 2740660278,
"label": "1",
"englishLabel": "1",
"odds": 1150,
"participant": "FC Lokomotiv Gomel",
"type": "OT_ONE",
"betOfferId": 2210856430,
"changedDate": "2020-04-14T09:11:55Z",
"participantId": 1003789012,
"oddsFractional": "1/7",
"oddsAmerican": "-670",
"status": "OPEN",
"cashOutStatus": "ENABLED"
},
{
"id": 2740660284,
"label": "X",
"englishLabel": "X",
"odds": 6750,
"type": "OT_CROSS",
"betOfferId": 2210856430,
"changedDate": "2020-04-14T09:11:55Z",
"oddsFractional": "23/4",
"oddsAmerican": "575",
"status": "OPEN",
"cashOutStatus": "ENABLED"
},
{
"id": 2740660286,
"label": "2",
"englishLabel": "2",
"odds": 11000,
"participant": "Khimik Svetlogorsk",
"type": "OT_TWO",
"betOfferId": 2210856430,
"changedDate": "2020-04-14T09:11:55Z",
"participantId": 1001024009,
"oddsFractional": "10/1",
"oddsAmerican": "1000",
"status": "OPEN",
"cashOutStatus": "ENABLED"
}
],
"tags": [
"OFFERED_PREMATCH",
"MAIN"
],
"cashOutStatus": "ENABLED"
}
],
"events": [
{
"id": 1006276426,
"name": "FC Lokomotiv Gomel - Khimik Svetlogorsk",
"nameDelimiter": "-",
"englishName": "FC Lokomotiv Gomel - Khimik Svetlogorsk",
"homeName": "FC Lokomotiv Gomel",
"awayName": "Khimik Svetlogorsk",
"start": "2020-04-17T14:30:00Z",
"group": "1\u00aa Divisi\u00f3n",
"groupId": 2000053499,
"path": [
{
"id": 1000093190,
"name": "F\u00fatbol",
"englishName": "Football",
"termKey": "football"
},
{
"id": 2000051379,
"name": "Bielorrusa",
"englishName": "Belarus",
"termKey": "belarus"
},
{
"id": 2000053499,
"name": "1\u00aa Divisi\u00f3n",
"englishName": "1st Division",
"termKey": "1st_division"
}
],
"nonLiveBoCount": 6,
"sport": "FOOTBALL",
"tags": [
"MATCH"
],
"state": "NOT_STARTED",
"groupSortOrder": 1999999000000000000
}
],
"prePacks": []
}

I am changing indexing of Cosmos DB but it is not working as it is supposed to be

I am Using Azure SQL API and my data is structured in the following way:
{
"deviceId": "123_123",
"comms": 0,
"engineSpdEnc": 0,
"currentTime": 1542185998605,
"deviceName": "mydevice2",
"siteId": 0,
"messageType": 2,
"data": {
"v5B3Freq": 0,
"v5B3Amp": 0,
"v5B4Freq": 0,
"v5B4Amp": 0,
"v5B5Freq": 0,
"v5B5Amp": 0,
"v6B6Freq": 0,
"v6B6Amp": 0,
"v6B7Freq": 0,
"v6B7Amp": 0,
"inletPres": 0
},
"EventProcessedUtcTime": "2018-11-14T09:01:42.6897624Z",
"PartitionId": 1,
"EventEnqueuedUtcTime": "2018-11-14T08:59:58.645Z",
"IoTHub": {
"MessageId": null,
"CorrelationId": null,
"ConnectionDeviceId": "device1",
"ConnectionDeviceGenerationId": "636758197942626855",
"EnqueuedTime": "2018-11-14T08:59:58.649Z",
"StreamId": null
},
"id": "1734dd0c-1bb5-d424-4946-e2c957bb3858",
"_rid": "lblPAOEu3xYCAAAAAAAAAA==",
"_self": "dbs/lblPAA==/colls/lblPAOEu3xY=/docs/lblPAOEu3xYCAAAAAAAAAA==/",
"_etag": "\"08008e15-0000-0000-0000-5bebe47c0000\"",
"_attachments": "attachments/",
"_ts": 1542186108 }
And by using Azure portal I have changed the indexing policy from default to following:
{
"indexingMode": "lazy",
"automatic": false,
"includedPaths": [
{
"path": "/*",
"indexes": [
{
"kind": "Range",
"dataType": "Number",
"precision": 3
},
{
"kind": "Range",
"dataType": "String",
"precision": 3
},
{
"kind": "Spatial",
"dataType": "Point"
}
]
}
],
"excludedPaths": [
{
"path": "/data/*"
}
]
}
According to this I have disable auto indexing policy and excluded the path in the /data/* that means
If I am going to query:
select * from c where c.data.v6B7Amp = 0
It should return nothing to me as there is no indexing forc.data.pressure , but I am getting all the records supposed to be in it.
Is it because I am using Azure portal to changing the indexing or anything else?
Firstly, you don't need to turn automatic indexing off or set the indexingMode to lazy, unless you have a reason to.
It appears that equality checks can work even if the path is excluded.
Where the excluded path will kick in is when you try to do something like an order by against that field.
Here is an example using your data data and your indexing policy:
When a path is excluded from indexing, query will fallback to do a full scan of all the documents in the collection to filter the results. That's the reason you are seeing results for your query.
It should be "path": "/data/?" The question mark refers to the specific value of the path, whereas the asterisk represents one or more paths as determined by the wildcard.

Microsoft.Azure.Search (sdk v3.0.3) don't return all the facets correctly

When I use Microsoft.Azure.Search (v3.0.3)'s "SearchAsync" and "Search" methods to return the indexed items, the sdk doesn't return all the facets.
However; when I try the same thing using Postman, it returns all the facets correctly.
Could this be a bug of the sdk (I believe it is as a direct call to an sdk method doesn't return the all the facets correctly - but couldn't find any records about this possible bug)? If yes, is there a fix for this for the sdk? Any help is appreciated.
UPDATE:
After spending some more time, I have found out that the bug is not .NET SDK Specific.
Both .NET SDK and REST API appear to have this problem and none of them returns all the facets. Can you please tell me is there a known bug for this and what is the fix for it?
Please see the following example;
There must be 2 Coaching facets but only 1 is returning from the Azure Search Service.
The new search query(facet specialisms added)
https://MYPROJECT-search.search.windows.net/indexes/myproject-directory-qa/docs?api-version=2016-09-01&$count=true&facet=specialisms&$filter=listingType eq 'Therapist'
"Coaching:Development coaching", --> This doesn't return as a facet.
"Coaching:Executive coaching", -->This returns fine.
"#search.facets": {
"specialisms#odata.type": "#Collection(Microsoft.Azure.Search.V2016_09_01.QueryResultFacet)",
"specialisms": [
{
"count": 5,
"value": "Anxiety, depression and trauma:Depression"
},
{
"count": 4,
"value": "Addiction, self-harm and eating disorders:Obsessions"
},
{
"count": 4,
"value": "Anxiety, depression and trauma:Post-traumatic stress"
},
{
"count": 4,
"value": "Coaching:Executive coaching"
},
{
"count": 4,
"value": "Identity, culture and spirituality:Self esteem"
},
{
"count": 4,
"value": "Relationships, family and children:Pregnancy related issues"
},
{
"count": 4,
"value": "Stress and work:Redundancy"
},
{
"count": 3,
"value": "Addiction, self-harm and eating disorders:Eating disorders"
},
{
"count": 3,
"value": "Anxiety, depression and trauma:Bereavement"
},
{
"count": 3,
"value": "Anxiety, depression and trauma:Loss"
}
]
},
{
"#search.score": 1,
"contactId": "df394997-6e94-e711-80ed-3863bb34db00",
"location": {
"type": "Point",
"coordinates": [
-2.58586,
51.47873
],
"crs": {
"type": "name",
"properties": {
"name": "EPSG:4326"
}
}
},
"profileImageUrl": "https://myprojectwebqa.blob.core.windows.net/profileimage/3e31457c-5113-4062-b960-30f038ce7bfc.jpg",
"locationText": "Bristol",
"listingType": "Therapist",
"disabledAccess": true,
"flexibleHours": true,
"offersConcessionaryRates": false,
"homeVisits": true,
"howIWillWork": "<p>Some test data</p>",
"specialisms": [
"Health related issues:Asperger syndrome",
"Health related issues:Chronic fatigue syndrome/ME",
"Addiction, self-harm and eating disorders:Addictions",
"Addiction, self-harm and eating disorders:Eating disorders",
"Addiction, self-harm and eating disorders:Obsessions",
"Anxiety, depression and trauma:Bereavement",
"Anxiety, depression and trauma:Depression",
"Anxiety, depression and trauma:Loss",
"Coaching:Development coaching",
"Coaching:Executive coaching",
"Identity, culture and spirituality:Self esteem",
"Identity, culture and spirituality:Sexuality",
"Relationships, family and children:Infertility",
"Relationships, family and children:Relationships",
"Stress and work:Redundancy"
],
"clientele": [
"Adults",
"Children",
"Groups"
],
"approaches": [
"CBT",
"Cognitive",
"Psychoanalytic",
"Psychosynthesis"
],
"sessionTypes": [
"Home visits",
"Long-term face to face work"
],
"hourlyRate": 50,
"fullName": "Test Name",
"id": "ZWUwNGIyNjYtYjQ5Ny1lNzExLTgwZTktMzg2M2JiMzY0MGI4"
}
Please see details below;
For my case I have found out that by default the Azure Search Service returns 10 of the facets. That is why I couldn't see all my facets.
After updating my search query as follows, I have fixed my problem and now I can see all my facets in the search results - please see the facet bit updated to this; facet=specialisms, count:9999.
https://MYPROJECTNAME-search.search.windows.net/indexes/MYPROJECTNAME-directory-qa/docs?api-version=2016-09-01&$count=true&facet=specialisms, count:9999&facet=clientele, count:9999&$filter=listingType eq 'Therapist'
For the Microsoft documentation, please see the following link.
"max # of facet terms; default is 10"
https://learn.microsoft.com/en-us/rest/api/searchservice/search-documents

Returning the "search term" along with result - Elasticsearch

In the elasticsearch module I have built, is it possible to return the "input search term" in the search results ?
For example :
GET /signals/_search
{
"query": {
"match": {
"focused_content": "stock"
}
}
}
This returns
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.057534903,
"hits": [
{
"_index": "signals",
"_type": "signal",
"_id": "13",
"_score": 0.057534903,
"_source": {
"username": "abc#abc.com",
"tags": [
"News"
],
"content_url": "http://www.wallstreetscope.com/morning-stock-highlights-western-digital-corporation-wdc-fibria-celulose-sa-fbr-ametek-inc-ame-cott-corporation-cot-graftech-international-ltd-gti/25375462/",
"source": null,
"focused_content": "Morning Stock Highlights: Western Digital Corporation (WDC), Fibria Celulose SA (FBR), Ametek Inc. (AME), Cott Corporation (COT), GrafTech International Ltd. (GTI) - WallStreet Scope",
"time_stamp": "2015-08-12"
}
}
]
}
Is it possible to have the input search term "stock" along with each of the results (like an additional JSON Key along with "content_url","source","focused_content","time_stamp") to identify which search term had brought that result ?
Thanks in Advance !
All I can think of, would be using highlighting feature. So it would bring back additional key _highlightand it would highlight things, that matched.
It won't bring exact matching terms, tho. You'd have to deal with them in your application. You could use pre/post tags functionality to wrap them up somehow specially, so your app could recognize that it was a match.
You can use highlights on all fields, like #Evaldas suggested. This will return the result along with the value in the field which matched, surrounded by customisable tags (default is <em>).
GET /signals/_search
{
"highlight": {
"fields": {
"username": {},
"tags": {},
"source": {},
"focused_content": {},
"time_stamp": {}
}
},
"query": {
"match": {
"focused_content": "stock"
}
}
}

Resources