Apache SOLR API - get ALL schemas for ALL collections in one single call - solrj

I have a SOLR server with several collections, and I need to check the schema for every collections.
I could do this in 2 steps:
a request to list all existing collections
GET /solr/admin/collections?action=LIST
one request for each collection to check the schema.
GET /solr/<collection-id>/schema
QUESTION: Is there any possibility to do this in one single request ?
Thanks.

Related

Do I have to use Django Models to use the API?

We are migrating our intranet application and have decided to choose the Django framework. We control all of our database via source control and managed scripts, so we do not use the migrate feature to create tables for us. Views and Tables can change, all business logic is held in the database.
I want to make Django API endpoint which is basically select * from my_table_or_view; and Django can return a JSON response with the column names and values. Some database tables have close to 100 columns each so I don't want to write out each and every field name and type just to return a query. What happens if we add another column to the view - will I have to update it in Django as well? What if I change the column type - will my application fail as well?
The frontend is written in VueJS - it makes a request to the API endpoint and should use the columns selected in the frontend, obviously if I remove a column it will break but I don't want to have to add the column in the django framework even if it is not used.
I've read the raw SQL queries section of the docs but i'm not sure where this applies to. Does this logic sit in the views section?
I've tried directing a URL endpoint in URLS.py to a custom class in views.py but not sure this is correct, does this logic need to be in a serializer?
I'd like the simplest method possible, potentially not using models, just raw SQL is fine.
One option for you is to sync your db to django models every time you change your schema and then use it normally, both ORM and raw SQL queries would be possible.
There's a function called inspectdb that does that natively, here is a reference to it
https://docs.djangoproject.com/en/3.1/ref/django-admin/#inspectdb

React-Rest app, where to fetch data from database

I have an App composed by back-end: Python with Django and Django REST, and front-end composed of React.
Right now I have Excel files with data, which I import with python in json format to the back-end, so they are available for a fetch in the front-end via REST-url like here.
I am now translating my data into a web-based-database to be queried into my app.
But I have questions regarding the structure of my app with this change.
I have url-based queries for my new database.
Should I continue to import the queries in the back-end REST framework and, from there, to React?
Or should I use the url-based queries directly inside my React, substituting the REST url calls?
You can get an idea by referring this url.
https://www.andreasreiterer.at/connect-react-app-rest-api/
this describing about how to bind data using REST APIs in react.
I have found some sources that presented me two ways of solving the problem
Case 1:
Have the JSON Query importation on server side in your back-end and pass this data to your API (REST in my case).
Basic source: https://www.valentinog.com/blog/tutorial-api-django-rest-react/
Pros:
Do not need to change the structure for the rest of my application. The data layer continues the same, as before I was working with an Excel file and now I just change to a JSON Query.
The connection between server-client continues to be straight forward
Credential systems can be applied more easily for the data will be stored in your API
Cons
Harder to implement
Connection between python and url queries must have individual settings (url-queries are usually browser-based, and some queries can't be performed in python)
Harder to debug
Case 2: Query data with a native fetch Javascript method and handle the data in client side.
Basic Sources:https://www.robinwieruch.de/react-fetching-data/
https://blog.hellojs.org/fetching-api-data-with-react-js-460fe8bbf8f2
Pros:
Faster and easier to implement
Easier to debug
Javascript handles queries in a simpler way than python
Cons:
Credential system can't be applied
Less secure/robust method
Double connection between client and server (client-queries and client-API), because the API would still be maintained to store local information.

Create Django RESTful service for execute an algorithm

I need to implement a Django RESTful service where I can run an algorithm and get the result.
On the server I need to have a CSV file with the records for the algorithm. A service, let's say /train will allow me to train a Random Forest with the data in the CSV file, and finally another service /predict will receive the parameters and send me the result. The problem is that I have this running as a script on my computer and I don't know how to structure it for a web application.
I have already done RESTful APIs in Django but this problem is different I think.
I won't need models?
What about the serializers?
My idea is to send a GET request to /predict with the parameters needed for the Random Forest and return the algorithm result.
Any suggestions? Or a public repo with a similar problem?
let say you have
train_view for '/train' with POST request.
result_view for /predict with GET request
Do you need models ?
I think you need that since in request /predict you are going to apply logic on the data you have given in request /train, so create model.
Do you need serializers
Since you have model, you can write modelserializer

Bulk Creation Of Items In Sitecore

I am using Sitecore 8, Update 3.
I am attempting to bulk create a couple thousand items that use a custom template. All of these items are created under one specific parent item.
The custom template has two fields which are Path [Single-Line Text] and Target [General Link].
The source of the data is in an old SQL database.
Is there a way to do this?
The Sitecore marketplace module Data Importer is a option for you.
Create a custom importer with the sitecore api is also possible, to speed up, you can disable the index rebuild.
Since your data is already in SQL Serve, you should take a look at using the SSIS Components for Sitecore, it was designed for importing exactly this kind of data in bulk into Sitecore using ETL.
You can find more info in the blog post Creating your first project with SSIS Components for Sitecore and there is also some good additional into in the Migrating to Sitecore: Going from WordPress to Sitecore with SQL Server Integration Services (SSIS) post.
The Integration Services Components for Sitecore is available on the Sitecore Marketplace, and it is compatible with Sitecore XP8.
I'll also add, if you are creating anything more than 100 items below a single parent item then this is not recommended Sitecore practice unless the items sit within an Item Bucket. Make sure you account for this, or split your items up into smaller sub-folders (e.g. year/month folders for news article type items)
In these scenarios you normally end up writing code to call the api and create the items programmatically rather than doing a generic import.
If you need to create a large amount of items I would recommend writing a console app to do this. You could use the Sitecore Item Web api to create items outside of the Sitecore context or investigate the new Entity Service api in Sitecore, both will be capable of creating large amounts of Sitecore items.
http://mikerobbins.co.uk/2015/01/06/entityservice-sitecore-service-client/
https://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/sitecore_item_web_api_developer_guide_sc65-66-usletter.pdf
If these don't float your boat you could always write async code to create the Sitecore items and have that executed by an aspx page in a Sitecore instance - works well for one off tasks.
Example of Asynchronous page processing in ASP.net webforms (.NET 2.0)

Django - load new objects via ajax

In django app I need to periodically check for if new object of particular model are created.
I want to this by ajax.
I was thinking about something like this:
render current timestamp into template, load current objects.
Then, every x seconds do ajax request and ask for objects which are created later then this timestamp.
What do you think? Is there maybe a better way?
What you want is a way for the client to know whether something has changed in the server. Generally there are three ways to stimulate this subscriber/broadcaster, or pull/push, relationship. The first is Ajax long-polling, which is roughly what you described. The second is implemented via WebSocket, which unfortunately not all browser supports. The third is HTTP streaming, or a long polling at the HTTP level. All three are available in https://github.com/ziyan/django-comet
A newer technology is Webhooks, which allows you to subscribe to server changes via URL (http://en.wikipedia.org/wiki/Webhook). Check it out here for an early Django adaptation: https://github.com/johnboxall/django_webhooks