Thanks Mikhail! I had seen this but had originally thought it wouldn't be
usable.  That said I think I was wrong.  I have an example that rewrites a
phrase query as a SpanQuery and then uses the PayloadNearQuery which seems
to work correctly.  I have done something similar for MultiPhraseQuery
(though I am not sure it is right at this point as I don't understand the
usage of the positions in the class at this point).  My first cut is shown
below (PF is just a PayloadFunction and not of much interest).  Does this
look correct?

MultiPhraseQuery phrase = (MultiPhraseQuery)query;
List<Term[]> terms = phrase.getTermArrays();
SpanQuery[] topLevelSpans = new SpanQuery[terms.size()];
for(int j = 0; j < terms.size(); j++) {
    Term[] internalTerms = terms.get(j);
    SpanQuery[] sq = new SpanQuery[internalTerms.length];
    for(int i = 0; i < internalTerms.length; i++) {
        sq[i] = new SpanTermQuery(internalTerms[i]);
    }
    topLevelSpans[j]= new SpanOrQuery(sq);
}
PayloadNearQuery pnq = new PayloadNearQuery(topLevelSpans,
phrase.getSlop(), true, new PF());
pnq.setBoost(phrase.getBoost());


It looks like to support Payloads in all the query types I would like to
support I'll need to rewrite the queries (or their pieces) to a
PayloadNearQuery or a PayloadTermQuery.  Is there a PayloadMultiTermQuery
that Fuzzy, Range, Wildcard, etc. type of queries could be rewritten to?
Again thanks I really appreciate the pointer.


On Jul 25, 2015 5:22 AM, "Mikhail Khludnev" <mkhlud...@griddynamics.com>
wrote:

> Does PayloadNearQuery suite for it?
>
> On Fri, Jul 24, 2015 at 5:41 PM, Jamie Johnson <jej2...@gmail.com> wrote:
>
> > Is there a way to consider payloads for scoring in phrase queries like
> > exists in PayloadTermQuery?
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
> <mkhlud...@griddynamics.com>
>

Reply via email to