I have a multi-tenant index in azure search and I want to populate it with several indexers, each uploading data from one specific tenant.
I want the search to be filtered by a field "tenantid". Each database that an indexer uses as a data source has the "tenantid" as it's name, but there is no function or option I found that enables adding a custom field mapping the name of the database to a field in the search results.
The naive solution to the problem is to add a field in each document in the DB containing the field "tenantid", but I would rather take this info from the database name and reduce my object size.
Any ideas? Thanks a lot.
There's currently no such field mapping function available. Please add this suggestion on Azure Search UserVoice.
To workaround, instead of adding the database name to each document, you can just include it by specifying a datasource query as follows:
SELECT c.id, c._ts, 'my_database' AS database FROM collection c WHERE c._ts >= #HighWaterMark
Related
Suppose I retrieve a row having a particular id using database connector.If I have to save a particular field lets say name in a variable for later use.How can I do that?
A very crude example would look like the one below:
You would need to go to the advanced section under the DB connector and you can configure the script to obtain the column values in the Output section.
I am using the Salesforce SOQL snap in a SnapLogic integration between our Salesforce instance and an S3 bucket.
I am trying to use a SOQL query in the Salesforce SOQL snap field "SOQL query*" to return the column names of an object. For example, I want to run a SOQL query to return the column names of the "Account" object.
I am doing this because SOQL does not allow "Select *". I have seen code solutions in Apex for this, but I am looking for a way to do it using only a SOQL query.
You want to query metadata? Names of available tables, names of columns you can see in each table, maybe types instead of real Account/Contact/... data, correct?
You might have to bump the version of the API up a bit, current is 47 / 48 so some objects might not be visible in your current one. Also - what API options you have? SOAP, REST? Is "Tooling API" an option? Because it has very nice official FieldDefinition table to pull this.
It's not perfect but this could get you started:
SELECT EntityDefinition.QualifiedApiName, QualifiedApiName, DataType
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName IN ('Account', 'Contact', 'myNamespace__myCustomObject__c')
I don't see the table in the REST API reference but it seems to query OK in Workbench so there's hope.
Generally try to Google around about EntityDefinition, FieldDefinition, EntityParticle... For example this is a decent shot at learning which tables are visible to you:
SELECT KeyPrefix, QualifiedApiName, Label, IsQueryable, IsDeprecatedAndHidden, IsCustomSetting
FROM EntityDefinition
WHERE IsCustomizable = true AND IsCustomSetting = false
Or in a pinch you could try to see which fields your user has permission to query. It's bit roundabout way to do it but I have no idea which tables your connector can "see".
Starting from API version 51.0 there's the FIELDS() function available: it lets you query all fields of a given object similar to "SELECT *"
Example:
SELECT FIELDS(ALL) FROM User LIMIT 200
Reference:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_fields.htm
This one is for the MS Azure Search team, unless someone else has run into this and found a resolution for it.
I'm creating an index which is importing data from a SQL Server Database. I would like to add a field to the index whose value is just "OK" for every document. This field does not exist in the database and we do not want to add it there.
Is it possible to add a hard-coded field to an Azure Search index which auto-populates with the given string (in this case, "OK") for all documents that get imported?
Injecting constant values isn't currently possible with indexers - you would need to add this to the table, or create a SQL query that SELECTs that value, and use that query as your Azure Search datasource.
However, we've seen several customers ask for this, so please vote for this suggestion: Provide field mapping function to inject a constant value into the index. Thanks!
We need to update a batch of documents based on some criteria in an Azure Search Index. The only way we can think of with the current implementation is :
Search for the required documents (e.g. Category = 1)
Create new documents using the document Id of the result
In the new documents update the required fields (e.g. Price = Price*1.1)
Use a Merge to Update the newly created documents to update existing ones.
The above code looks like we are back in the 1960s or that we have a few screws loose in our brain! Is this the only way to achieve this in Azure Search?
We are using the .NET SDK.
Your algorithm to update documents matching a query is indeed correct. One note: use filter instead of full-text search - it will be more efficient.
Azure Search is a search engine, not a general-purpose database, so it doesn't directly support an equivalent of SQL's UPDATE ... WHERE pattern.
I have added a SQL database as external content type and created a SharePoint list based on that. I saw that while configuring it, there is an option to set a filter. I want to filter records based on the URL parameter which the list receives. I tried setting up a column_name = parameter filter, but how do I pass the query string parameter from the URL to this filter parameter?
For example, if I have 100 records for Basketball players, and the URL is list.aspx?team=pacers I want the list to load only the 10 pacers records from the SQL database. I don't want to load all the records and then filter the list using UI.
Thanks!
You should know about Data Source Filters
When you create an external content type filter, which is known as a
Data Source Filter, the filter operation occurs within the SQL Server
database. This is important when you are working with lots of data
because you can offload processing from SharePoint products to the
external database and gain performance improvements. After you create
the external list, you can use the Data Source Filter by creating a
view that specifies different filter values in the Data Source Filter
section of the List View settings page.
Read more, How to: Create external content types for SQL Server in SharePoint 2013