Refactor Indexing Code

Make index code more concise and add $fieldnames for indexing.

33294-query-text-search
Refactor Selector Code

Change selector code to use iolist_to_binary and more concise
recursive calls.

33294-query-text-search