Search in nested json (Azure Search) - azure-cognitive-search

I have CosmosDB (documentDB) with JSON, that is looking like this:
{
"id": "59082f71-def1-47cc-j6w2-3fd8c0831e9c",
"name": "Bilbo",
"address":
{
"street": "bla-bla-bla",
"city": "London",
"country": "Great Britain"
}
}
But when I am trying to use Azure search seems that I can't use Edm.ComplexType as it is not supported
and also I can't use Collection(Edm.String) as I have multiple fields.
Here is how I am trying to get fields:
SELECT c._rid, c.id, c.name, c.address.street as street, c.address.city as city, c.address.country as country FROM c WHERE c._ts >= #HighWaterMark ORDER BY c._ts

The SELECT query you use looks fine. If you defined your Azure Search's data-source\indexer via Azure portal (as opposed to via REST API), you might have hit a known issue where the data source query is being ignored – we are currently working to fix that.
Meanwhile, here’s a workaround:
Make sure your data source query was indeed ignored: In Azure portal, go to the ‘Overview’ page of your search service, click on the “Data Sources” tab and select your data source.
In the data source page, select “Edit” - do you see the correct SELECT query in the “Query” text-box? If not correct it with your query and click “OK”
Make sure your index contains the additional fields that you wanted\selected (street, city & country): Go to the “Overview” page again, select your index from the “Indexes” tab and then select the “Fields” tab in the index page – if some fields are missing, you can add them and click “Save”
Rerun or recreate your indexer: You can either re-run your existing indexer by navigating back to the “Overview” page, selecting your indexer from the “Indexers” tab, click “Reset” and then “Run”
Alternatively you may delete the existing indexer (and index, if you don’t have any data you need there), and create a fresh one by clicking the “Import Data” from the “Overview” page – this time selecting an “Existing data source” in the first step.
I hope this helps.

Related

How can I blend Google Sheets data with another data source?

I've connected Google Search Console as a data source and added a New Field called "Brand or Non-brand".
The "Brand or Non-brand" field take the Google Search Console "Query" dimension as a variable. The field uses a CASE statement to determine if the query includes a brand term like "Pepsi" or a non brand term like "Fizzy Drinks." This bit all works without error. See this example;
CASE
WHEN REGEXP_MATCH(Query, ".*pepsi.*") THEN "Brand"
ELSE "Non-brand"
END
I want to know if I can use a Google Sheet to store the various brand terms? The Google Sheet would be a new data source and would have a column called "brand terms." This would include things like Pepsi, Coke, Fanta, Dr Pepper.
I connected the data sources but I couldn't get the fields to appear in the other data source. For example "brand terms" wont appear in the CASE statement in the Search Console Data source. I experimented with blending the data, but was unsuccessful.
I guess it's going to look a bit like this;
CASE
WHEN REGEXP_MATCH(Query, GoogleSheet_BrandTerms) THEN "Brand"
ELSE "Non-brand"
END
Would anybody have any advice?

How can i retrieve the Product Name from a Opportunity in Salesforce SOQL?

I have created an Opportunity in Salesforce with Opportunity Line Items.
I run the following query and the
SELECT Amount, Account.Name, Account.AccountNumber, Name,
(
SELECT Quantity, UnitPrice, ProductCode, Product2.Name FROM
OpportunityLineItems
)
FROM Opportunity
The OpportunityLineItems column returned in the result are as follows.
[{"Quantity":"1","UnitPrice":"10","ProductCode":"code1","Product2":"[object Object]"}]
If i drill down to the opportunity in Salesforce UI I see Under Products(Test Price Book) the Line.
If i drill down into the line the Name is name1.
So why is it returning [object Object] and not the name as requested by the query ?
It probably returns the results fine, it's just your connecting library that messes up and shows JavaScript object placeholder instead of actual nested object. I've seen it also show up in Salesforce's own Developer Console.
What do you use? A raw REST API call (using workbench -> utilities -> rest explorer, Postman or something else) should produce this
(I added a WHERE clause)
/services/data/v52.0/query?q=SELECT+Amount,+Account.Name,+Account.AccountNumber,+Name,++(+++SELECT+Quantity,+UnitPrice,+ProductCode,++Product2.Name+FROM++++OpportunityLineItems+)+FROM+Opportunity+WHERE+Id+IN+(SELECT+OpportunityId+FROM+OpportunityLineItem)+LIMIT+5
If you really connect from javascript - see if you can JSON.stringify(results) or something like that before logging it, should give you better structure? Or step through the code with debugger...
But no, the data should be there all right, just doesn't render well on your end.

Insert missing values in Sharepoint Online usning Azure Logic App

I've a SQL Server table with a column Manufacturer with 4 rows:
Integral Coach Factor
Bharat Heavy Electricals Limited
Chittaranjan Locomotive Works
Golden Work Railway Workshop
Same data is available in a Sharepoint List as well:
Integral Coach Factor
Bharat Heavy Electricals Limited
Golden Work Railway Workshop
My task is to run a logic app every 24 hours and insert the missing values in the Sharepoint list. For the above example, I would need to insert only Chittaranjan Locomotive Works in the sharepoint as it is missing in the sharepoint list.
I'm new to Azure Logic App, and need some help to accomplish the task.
Any help will be highly appreciated.
For your requirement, please refer to my logic app shown as below:
1. Now I have a table shown like:
2. Go to logic app, use "Get rows(V2)" action to get rows of the table.
3. Then use "Get items" action to get all of the items in your sharepoint list.
4. Use "Select" action to select the "Title" of each item of the sharepoint list. And input "Manufacturer" as "key" of each "Title".
5. After that, use "For each" to loop the value from "Get rows(V2)".
6. In "For each" loop, add a "Compose" action with content like below:
7. After the "Compose", add a "Condition" to judge if it exists in sharepoint list. Choose Output of "Select" action as content of first input box and choose Output of "Compose" action as content of second input box.
8. If "false", create item with current "Manufacturer" as its "Title".

Get Display Name for License SKU in Microsoft Graph

I am trying to use Microsoft Graph to capture the products which we have licenses for.
While I can get the skupartname, that name is not exactly display-friendly.
I have come across DisplayName as a datapoint in almost all the API calls that give out an object with an id.
I was wondering if there was a DisplayName for the skus, and where I could go to get them via the graph.
For reference, the call I made was on the https://graph.microsoft.com/v1.0/subscribedSkus endpoint following the doc https://learn.microsoft.com/en-us/graph/api/subscribedsku-list?view=graph-rest-1.0
The following is what's returned (after filtering out things I don't need), and as mentioned before, while I have a unique identifier which I can use via the skuPartNumber, that is not exactly PRESENTABLE.
You might notice for some of the skus, it difficult to figure out what it is referring to based on the names in the image of the Licenses page posted after the output
[
{
"capabilityStatus": "Enabled",
"consumedUnits": 0,
"id": "aca06701-ea7e-42b5-81e7-6ecaee2811ad_2b9c8e7c-319c-43a2-a2a0-48c5c6161de7",
"skuId": "2b9c8e7c-319c-43a2-a2a0-48c5c6161de7",
"skuPartNumber": "AAD_BASIC"
},
{
"capabilityStatus": "Enabled",
"consumedUnits": 0,
"id": "aca06701-ea7e-42b5-81e7-6ecaee2811ad_df845ce7-05f9-4894-b5f2-11bbfbcfd2b6",
"skuId": "df845ce7-05f9-4894-b5f2-11bbfbcfd2b6",
"skuPartNumber": "ADALLOM_STANDALONE"
},
{
"capabilityStatus": "Enabled",
"consumedUnits": 96,
"id": "aca06701-ea7e-42b5-81e7-6ecaee2811ad_0c266dff-15dd-4b49-8397-2bb16070ed52",
"skuId": "0c266dff-15dd-4b49-8397-2bb16070ed52",
"skuPartNumber": "MCOMEETADV"
}
]
Edit:
I am aware that I can get "friendly names" of SKUs in the following link
https://learn.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference
The problem is that it contains ONLY the 70ish most COMMON SKUs (in the last financial quarter), NOT ALL.
My organization alone has 5 SKUs not present on that page, and some of our clients for who we are an MSP for, also have a few. In that context, the link really does not solve the problem, since it is not reliable, nor updated fast enough for new SKUs
You can see a match list from Product names and service plan identifiers for licensing.
Please note that:
the table lists the most commonly used Microsoft online service
products and provides their various ID values. These tables are for
reference purposes and are accurate only as of the date when this
article was last updated. Microsoft does not plan to update them for
newly added services periodically.
Here is an extra list which may be helpful.
There is a CSV download available of the data on the "Product names and service plan identifiers for licensing" page now.
For example, the current CSV (as of the time of posting this answer) is located at https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing%20v9_22_2021.csv. This can be downloaded, cached and parsed in your application to resolve the product display name.
This is just a CSV format of the same table that is displayed on the webpage, which is not comprehensive, but it should have many of the products listed. If you find one that is missing, you can use the "Submit feedback for this page" button on the bottom of the page to create a GitHub issue. The documentation team usually responds in a few weeks.
Microsoft may provide an API for this data in the future, but it's only in their backlog. (source)

How to get salesforce Activity id

I have a salesforce query that extracting users time report
SELECT ID,Logged_Date__c ,CreatedBy.Email, CreatedBy.id, CreatedBy.Name, Time_Spent_Hours__c, Activity__c, CaseId__r.CaseNumber, CaseId__r.Account.id, CaseId__r.Account.Name , Utilized__c
FROM Time_and_Placement_Tracking__c
The Activity__c returns with the activity text.
I was trying to use Activity__c.Id, Activity__r etc. but all returns with error.
Is there a way to get the Activity id?
Verify these
You need to get to the object definition and see the field info. You can use workbench or any other API tool if you are familiar with and get the object and field def's.
Check the data type for Activity__c field. It should be a lookup/master relation. If it is not, find the field which ties to Activity object.
Open the field to get the API name and use that in the query with a '__r' extension.

Resources