AntonShuvaev/elasticsearch4idea

Add ability to sort document keys alphabetically

chrispappas opened this issue · 3 comments

Is your feature request related to a problem?

With many fields in a large document, it can be difficult to find the field one is looking for in the Data Browser view. My documents are returned with the fields in (random?) non-alphabeticaly sorted order.

image

Describe the solution you'd like

An option in the toolbar at the top to sort the JSON _source object by keys, alphabetically, or a setting to make this the default ordering of _source fields.

Additional context

No response

You can achieve this with the built-in JSON sorting feature. Place the cursor on the response or select the entire response, press Alt + Enter, and then choose "Sort properties alphabetically" from the intentions menu.

I had no idea I could do this in the IDE natively. Been using Jetbrains editors for almost a decade and TIL. Thanks again!

Thoughts on adding it as a single button/option in the plugin itself though? This meets my needs, now that I know I can do it, but other users may benefit from having it. I'd also like to be able to have it just ALWAYS sort the properties. The extra few clicks/actions are not a big deal, but it's worth asking at least.

Edit: I just realized that this only applies to the current object at the cursor, not the entire JSON response. Having the button perform the sorting on all properties by default is still a feature I'd like to request

Thank you for your suggestion! I've decided not to add a separate button for this feature. This decision is based on keeping the plugin interface streamlined and avoiding added complexity that might not be necessary for all users. However, to sort properties for the entire response, you can select the whole response (Cmd + A) and then use the "Sort properties alphabetically" option from the intentions menu.