Hi Team,
Scenario
----------
We are using FlexMonster Pivot with dynamic data. Each user will have a specific dataset based on his selection of pivot parameters. This dataset is stored in our database.
Every day we query the pivot dataset and create user files as a batch process at midnight. When the user logs in, and selects a module, the user files are downloaded on to the browser after which the dashboard and/or reports are displayed on the page.
New Requirement
---------------
We have subscribed to FlexMonster Data. We would like to use FlexMonster Data to connect to the user specific pivot dataset. But for the same, we will have to create indexes on the Data Server dynamically.
Do you provide Admin APIs that can be called from our application in order to create the indexes online whenever the user saves the dataset in our application? If yes, do provide references. If no, please provide an idea on how this can be done?
Regards,
Vaibhav
Hello, Vaibhav!
Thank you for your question.
We kindly recommend customizing the Flexmonster Data Server as a DLL to add new indexes in the runtime.
The algorithm is the following:
1. Add a new endpoint to the controller, for example, '/addindex'. As an additional step, it can be moved to a separate controller.
2. On the client side, pass all necessary options with the request to the newly created endpoint
3. On the Data Server side, create the custom service for adding new indexes. In the following thread, we have provided you with the code snippet of JsonIndexService
, which adds indexes in runtime: https://www.flexmonster.com/question/api-information-for-data-server/.
Here is mentioned example embedded into the controller:
[Route("api")]
[ApiController]
public class JsonIndexController: ControllerBase
{
public IDataStorage _dataStorage;
public IOptionsMonitor<DatasourceOptions> _datasourceOptions;
public JsonIndexController(IOptionsMonitor<DatasourceOptions> datasourceOptions, IDataStorage dataStorage)
{
_datasourceOptions = datasourceOptions;
_dataStorage = dataStorage;
}
[Route("addindex")]
[HttpPost]
public async Task<IActionResult> CreateIndex([FromBody] Request indexOptions)
{
//create new index here
var jsonIndexOptions = new JsonIndexOptions(indexOptions.Path);
jsonIndexOptions.RefreshTime = indexOptions.RefreshTime;
_datasourceOptions.CurrentValue.Indexes.Add(indexOptions.IndexName, jsonIndexOptions);
await _dataStorage.GetOrAddAsync(indexOptions.IndexName);
return new JsonResult("sussessfully added index");
}
}
Please let us know if this approach works for you.
Regards,
Solomiia
Hello, Vaibhav!
Hope you are having a great week.
Our team is wondering if you had some time to try the suggested approach of using Flexmonster Data Server as DLL with the custom endpoint to add new indexes in the runtime. Could you please let us know if it works for your case?
Looking forward to hearing from you.
Regards,
Solomiia
Hello, Vaibhav!
Hope you are doing well.
Just checking in to ask if the suggested approach of using Flexmonster Data Server as DLL with the custom endpoint was helpful in adding new indexes in the runtime.
Looking forward to your response.
Kind regards,
Solomiia
Hi Solomiia,
Sorry for the delayed response. I have started working on the data server as DLL. I will update you once I try the code you have suggested.
Regards,
Vaibhav P.
Hello, Vaibhav!
Thank you for getting back to us.
We will be waiting for the following updates on the case.
Feel free to reach out to us if any other questions arise.
Regards,
Solomiia