Hi FM Dev/Support Team,
Due to length restriction of json setting file, we are thinking of reading settings from a DB and injecting to FM Dataserver dll. Is it possible to inject custom settings into Dataserver dll or suggest us some way, how to do it.?
Regards,
Shahul
Hi, Shahul!
Thank you for your question.
You can configure Flexmonster Data Server indexes in the Startup.cs
file instead of the JSON settings file to bypass the size restrictions.
Create & configure the index
This code snippet is responsible for configuring a Database index. To create a JSON/CSV index, use JsonIndexOptions/CsvIndexOptions
class in options.Indexes.Add
method.
services.Configure<DatasourceOptions>((options) =>
{
options.Indexes = new Dictionary<string, IndexOptions>();
options.Indexes.Add("custom-index", new DatabaseIndexOptions("databaseType", "connectionString", "query"));
});
Configure data storage options
To set general options in code, you should use a similar code.
services.Configure<DataStorageOptions>((options) =>
{
options.CacheSizeLimit = 100;
options.KeepDataOnRefresh = false;
options.DataRefreshTime = 60;
});
You can also partly load configs from the JSON settings file using the line of code below, but loading it will override the settings previously made in the Startup.cs
file.
services.ConfigureFlexmonsterOptions(Configuration);
Feel free to contact us if you have more questions.
Best Regards,
Maksym
Hi, Shahul!
Just checking in to ask if you had time to try adding indexes in the code. Could you please let us know if our response helped?
Best Regards,
Maksym
Hi Maksym,
Thanks for your response.
Sorry for late reply.
We had implemented that in different way before getting this response. We created an custom configuration extension. Added entity configuration. Used this configuration in CreateHostBuilder method in Program.cs. and injected via config.AddEntityConfiguration(). This solution works..
Just analysed above code provided by you. Here we have to enter index name, db conn string and query. our frontend application has different tabs based on clients requirement. Each tab has data view and its associated 5-15 index queries. In the above approach suggested by you, we have to enter multiple indexes inside application, where in our approach all the indexes are stored in db table as key-value pair and through entity framework we can read and push in one shot. We can execute index queries as scripts and its easy for maintenance.
Regards,
Shahul
Hi, Shahul!
We are happy to hear that you found the solution for your use case.
Please let us know if any other questions arise.
Regards,
Maksym
Hi @Shahul, if it is possible to share your solution.
@Maksym, there is nothing different than default implementation, it seems it is still using configuration file to add indexes instead of database.
The question is about storing configurations in database instead of appsettings.json or something similar. I have the similar issue. We have a SaaS app and lots of tenants. So there may be hundreds of thousands of indexes. Or there may be a different method that you can recommend.
Hi, Patrick!
Thank you for writing to us.
Firstly, based on your input, we recommend using another data source instead of Flexmonster Data Server. Flexmonster Data Server's architecture implies loading the entire dataset of each created index into RAM. We believe that the mentioned number of indexes would require very large RAM capacities, which may be too costly. We have provided the reply in your newer ticket, with proposed alternatives to FDS that may fit your use case better https://www.flexmonster.com/question/store-indexes-in-database-instead-of-configurations/
Speaking of the solution described in our answer, it is just a part of the full solution. It illustrates how to add indexes via code instead of using the appsettings.json
configuration. The provided code looks similar to the config file approach since the connection properties are hard-coded. However, it is also possible to retrieve the data from your database and use it for index creation in Startup.cs
. Since there are many options for implementing database storage for indexes, it would be difficult for us to provide a single generic solution. Still, since your number of indexes might grow to hundreds of thousands, we highly recommend using a different approach instead of Flexmonster Data Server.
We hope you will find this information helpful.
Best Regards,
Maksym