HTML and AI - A simple request, and a beautiful response for ElasticSearch without Kibana
THE PROBEM
I recently installed an ElasticSearch in a Docker environment and I want to be sure that it is working, before waiting the consumers start to connect to it.
The Container is started using a volume which was cloned from another Docker installation, so it was not empty: we already have some indexes and some documents.
I want to be sure that everything was available but I don't have any Kibana installation (and I can't install it at all). So only API was available and I need to check something ElasticSearch REST APIs
THE FIRST SOLUTION
If you ask to Microsoft Copilot how to interact with ElasticSearch api, it will reply by suggesting:
- curl
- scripting
- postman
But the interaction is not so human readable and it is quite noisy to write the commands. I want to have something to be easily used but I don't want to spend to much time on that. I need an accelerator
THE SECOND SOLUTION
I know that there is such an api to ask to ElasticSearch the list of indexes. And I also know that there is an api to perform search on specific index, by limiting the search with query and with page size and documents for page.
Ok let me ask something to Ms Copilot.
This is what I asked
I need an html page where it contains an empty input box (large enough) that will contain the root address of an elasticSearch installation. In the page there is also an empty select which is populated after press a button that perform a search on the elasticSearch retrieving all the index list. Then I need to perform query on the index I can select from the select. The query is structured by having a text area in which I can insert the "query" element of search api and 2 select element which will contain the page size (from 1 to 50) and the page number which is adapted on change of the page size. and is obtained from the docs.count value of the selected index. The result of the query is then shown in a "p" element. Please apply a nice stylesheet from one of the best you can find on internet.
It is clear right? But what was produced was not so nice for me. The page size and doc for page was never used with the "search" so i specified
the query should be performed using the page number as "from", the page size as "size" and the query textbox as "query"
But the output was not so nice to me. I mean..having just an giant json was not the best solution, so I decided to ask another thing, more specific
Giving the previous html page, is there a way to show the query result in nested accordion element one for each json node element?
THE RESULT
And finally it produced this
The page size was perfect generated
And the secondo select depends on the number of docs and the page size
And what you see in the result are accordion, one for each json node
CONCLUSION
If I have to create all of this by my hands, I think that I would need some hours. Instead it took just few minutes. Of Course you need to know exactly what to ask and give feedback (as I did) to Copilot but the generated page was very nice, useful and also easy to be managed.
This doesn't mean that developers will be replaced by AI, but this is really a 10X if you are able to explain exactly what you need. Senior will be involved more on quality that on just produce code.
Commenti
Posta un commento