The contextual menu that appears when control-clicking a toolbar item has an additional option: "Keep Item Visible". When checked, the item will no longer disappear when the window becomes too narrow to show the entire toolbar, instead making another item vanish into the menu indicated by the � arrows. This option does not appear for spaces, flexible spaces, or separator lines.
So you could have a search field on the rightmost side but have it remain in the toolbar and have icons in the middle of the toolbar disappear instead if the window shrinks.