The index of a Lie algebra is $\mathrm{ind}(\mathfrak{g})=\mathrm{min}_{\lambda \in \mathfrak{g}^{*}} \mathfrak{g}^{\lambda}$$\mathrm{ind}(\mathfrak{g})=\mathrm{min}_{\lambda \in \mathfrak{g}^{*}} \mathrm{dim} \mathfrak{g}^{\lambda}$, where $\mathfrak{g}^{\lambda} = \lbrace x\in \mathfrak{g} \mid \lambda\circ \mathrm{ad}_{x} = 0 \rbrace$.
Is there any way to classify all complex n-dimensional nilpotent Lie algebra $\mathfrak{g}$ whose index is $\mathrm{ind}\ \mathfrak{g} = n-2$ ?
Examples would be the filiform Lie algebras, if I am not mistaken, e.g. $\mathfrak{g}$ generated by $\{x_1, \ldots, x_n\}$ subject to $[x_1,x_i]=x_{i+1}$ for $2\leq i < n$.