I'm sure I can get it working the way I started, using CharFilter, however perhaps it's possible to implement in a more generic and Lucene-like query syntax utilizing position info from the index:
This would mean that the phrase must be anchored between N'th and M'th token position in the field. Negative values for N/M would mean relative to the end. Thus "^quick fox$" could be written
Or if you require the phrase to be within first 10 words OR last 10 words:
title:("quick fox"@0:10 OR "quick fox"@-10:-0)
Requiring a term to be exactly @ position 3 would be:
If this syntax is feasible, we could use same syntax in eDisMax's pf param in order to tell it to add a position constraint when forming the pf part of the query:
This would only generate a phrase match on title if the phrase is an exact match of the whole field.
Potential issues with multi-valued fields? Is the field delimiter clearly marked or is it only an increment gap?
Would it be easy to parse such a syntax and generate a Lucene query with the position constraints?