Your filtered query should work the same as a SpanFirst, yes. I didn’t add a shortcut just because you can do it this way, but feel free to add it if you think it’s useful!
Re sloppy phrases, this one is trickier. The closest you can get at the moment is an unordered near, but that’s not the same thing as it doesn’t take transpositions into account when calculating the slop. I think it should be possible to write something that works similarly to SloppyPhraseMatcher, but as always the tricky part is in dealing with duplicate entries. I have some ideas but they’re not ready to commit yet, unfortunately. In terms of your suggested replacements: maxwidth will give you the equivalent of a SpanNearUnordered. Maxgaps gives a restriction on how many internal holes there are in the query, so works better if the constituent intervals are not necessarily single terms. > On 21 Sep 2020, at 18:47, Dawid Weiss <dawid.we...@gmail.com> wrote: > > > For what it is worth, I would be also interested in answers to these > questions. ;) > > On Mon, Sep 21, 2020, 19:08 Uwe Schindler <u...@thetaphi.de > <mailto:u...@thetaphi.de>> wrote: > Hi all, hi Alan, > > I am currently rewriting some SpanQuery code to use IntervalQuery. Most of > the transformations can be done quite easily and it is also better to read > after transformation. What I am missing a bit is some document to compare the > different query types and a guide how to convert those. > > I did not find a replacement for SpanFirstQuery (or at least any query stat > takes absolute positions). I know intervals more deal with term intervals, > but I was successful in replacing a SpanFirstQuery with this: > IntervalsSource term = Intervals.term("foo"); > IntervalsSource filtered = new > FilteredIntervalsSource("FIRST"+distance, term) { > @Override > protected boolean accept(IntervalIterator it) { > return it.end() < distance; // or should this be <= distance??? > } > }; > Query = new IntervalQuery(field, iv2); > > I am not fully sure if this works under all circumstances 😊. To me it looks > fine and also did work with more complex intervals than "term". If this is > ok, how about adding a "first(int n, IntervalsSource iv)" method to Intervals > class? > > The second question: What's the "closest" replacement for a PhraseQuery with > slop? Should I use maxwidth(slop + 1) or maxgaps(slop-1) or maxgaps(slop). I > know SpanQuery slops cannot be fully replaced with intervals, but I don't > care about those SpanQuery bugs. > > Uwe > > ----- > Uwe Schindler > Achterdiek 19, D-28357 Bremen > https://www.thetaphi.de <https://www.thetaphi.de/> > eMail: u...@thetaphi.de <mailto:u...@thetaphi.de> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > <mailto:java-user-unsubscr...@lucene.apache.org> > For additional commands, e-mail: java-user-h...@lucene.apache.org > <mailto:java-user-h...@lucene.apache.org> >