How to require two analyzers to match terms AND positions in full-text searching?

Hello, I have an Elasticsearch mapping in which one field, surname, is analyzed according to ngram and phonetic analyzers. I previously asked about how to ensure that BOTH queries match each surname, essentially so that the ngram results can be used to restrict the result set returned from the phonetic analyzers. dadoonet suggested using nested documents, which I successfully did – tokenizing the field on the client side and passing it during import as separate documents.

However, we are now using a query_string query to query the full text of each record in parallel with some extracted data like years. We would like to be able to add the phonetic queries to this, but again using the same ngrams to restrict the result set.

Essentially, I think I "just" need the two analyzers (phonetic and ngram) to be run and to require at query time that the term positions match. Otherwise I would have to create a nested document for every word, which seems a bit like it will explode the document count.

I had a feeling that span queries would help but it doesn't look like those would work with query_string. I also considered creating a custom phonetic plugin that creates different tokens that apply my ngram logic, but we are unfortunately very low budget and can't afford hosting plans that let us upload custom plugins.

Any ideas? Many thanks!

Ben

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.