You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by William Bell <bi...@gmail.com> on 2015/10/19 00:46:37 UTC

PayloadTermQuery deprecated

Wondering how to change my payload based on example:

https://lucidworks.com/blog/2014/06/13/end-to-end-payload-example-in-solr/

PayloadTermQuery and BooleanQuery are deprecated in 5.3.x

@Override
public Query parse() throws SyntaxError {

    if (qstr == null || qstr.length() == 0) return null;
    BooleanQuery q = new BooleanQuery();
    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
        qstr = qstr.substring(1,qstr.length()-1);
    }
    String[] nvps = StringUtils.split(qstr, " ");
    for (int i = 0; i < nvps.length; i++) {
        String[] nv = StringUtils.split(nvps[i], ":");
        if (nv.length > 1) {
          if (nv[0].startsWith("+")) {
            q.add(new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]),
              new AveragePayloadFunction(), false), Occur.MUST);
          } else {
            q.add(new PayloadTermQuery(new Term(nv[0], nv[1]),
              new AveragePayloadFunction(), false), Occur.SHOULD);
          }
        }
    }
    return q;
}


-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076

Re: PayloadTermQuery deprecated

Posted by Alan Woodward <al...@flax.co.uk>.
I've added the includeSpanScore parameter back in for 5.4, so you might do better to wait until that's released.  Otherwise, the code looks correct to me.

Alan Woodward
www.flax.co.uk


On 19 Oct 2015, at 21:57, William Bell wrote:

> Alan,
> 
> Does this code look equivalent? And how do I change PayLoadScoreQuery to do
> a Custom Similarity?
> 
> PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> AveragePayloadFunction());
> 
> @Override
> public Query parse() throws SyntaxError {
> 
>    if (qstr == null || qstr.length() == 0) return null;
>    //BooleanQuery q = new BooleanQuery();
>    BooleanQuery.Builder q = new BooleanQuery.Builder();
>    q.setDisableCoord(true);
>    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
>        qstr = qstr.substring(1,qstr.length()-1);
>    }
>    String[] nvps = StringUtils.split(qstr, " ");
>    for (int i = 0; i < nvps.length; i++) {
>        String[] nv = StringUtils.split(nvps[i], ":");
>        if (nv.length > 1) {
>          if (nv[0].startsWith("+")) {
>              SpanTermQuery sq = new SpanTermQuery(new
> Term(nv[0].substring(1), nv[1]));
>              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> AveragePayloadFunction());
>              q.add(psq, Occur.MUST);
>            //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
> nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
>          } else {
>            //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
> AveragePayloadFunction(), false), Occur.SHOULD);
>              SpanTermQuery sq = new SpanTermQuery(new Term(nv[0], nv[1]));
>              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> AveragePayloadFunction());
>              q.add(psq, Occur.SHOULD);
>          }
>        }
>    }
>    // return q;
>    return q.build();
> }
> 
> 
> On Mon, Oct 19, 2015 at 1:49 AM, Alan Woodward <al...@flax.co.uk> wrote:
> 
>> Hi Bill,
>> 
>> This looks like an oversight on my part when migrating the payload scoring
>> queries - can you open a JIRA ticket to add 'includeSpanScore' as an option
>> to PayloadScoreQuery?
>> 
>> As a workaround, you should be able to use a custom similarity that
>> returns 1 for all scores (see IndexSearcher.NON_SCORING_SIMILARITY for an
>> implementation that returns 0, you could just clone that and change
>> SimScorer.score())
>> 
>> Alan Woodward
>> www.flax.co.uk
>> 
>> 
>> On 19 Oct 2015, at 00:39, William Bell wrote:
>> 
>>> Here is my first stab at it. Thoughts?
>>> 
>>> Question:
>>> 
>>> new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]), new
>>> AveragePayloadFunction(), false)
>>> 
>>> How do I handle the "false"  ? It means boolean includeSpanScore
>>> 
>>> 
>>> @Override
>>> public Query parse() throws SyntaxError {
>>> 
>>>   if (qstr == null || qstr.length() == 0) return null;
>>>   //BooleanQuery q = new BooleanQuery();
>>>   BooleanQuery.Builder q = new BooleanQuery.Builder();
>>>   q.setDisableCoord(true);
>>>   if (qstr.length() > 1 && qstr.startsWith("\"") &&
>> qstr.endsWith("\"")) {
>>>       qstr = qstr.substring(1,qstr.length()-1);
>>>   }
>>>   String[] nvps = StringUtils.split(qstr, " ");
>>>   for (int i = 0; i < nvps.length; i++) {
>>>       String[] nv = StringUtils.split(nvps[i], ":");
>>>       if (nv.length > 1) {
>>>         if (nv[0].startsWith("+")) {
>>>             SpanTermQuery sq = new SpanTermQuery(new
>>> Term(nv[0].substring(1), nv[1]));
>>>             PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
>>> AveragePayloadFunction());
>>>             q.add(psq, Occur.MUST);
>>>           //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
>>> nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
>>>         } else {
>>>           //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
>>> AveragePayloadFunction(), false), Occur.SHOULD);
>>>             SpanTermQuery sq = new SpanTermQuery(new Term(nv[0],
>> nv[1]));
>>>             PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
>>> AveragePayloadFunction());
>>>             q.add(psq, Occur.SHOULD);
>>>         }
>>>       }
>>>   }
>>>   // return q;
>>>   return q.build();
>>> }
>>> 
>>> 
>>> On Sun, Oct 18, 2015 at 4:46 PM, William Bell <bi...@gmail.com>
>> wrote:
>>> 
>>>> Wondering how to change my payload based on example:
>>>> 
>>>> 
>> https://lucidworks.com/blog/2014/06/13/end-to-end-payload-example-in-solr/
>>>> 
>>>> PayloadTermQuery and BooleanQuery are deprecated in 5.3.x
>>>> 
>>>> @Override
>>>> public Query parse() throws SyntaxError {
>>>> 
>>>>   if (qstr == null || qstr.length() == 0) return null;
>>>>   BooleanQuery q = new BooleanQuery();
>>>>   if (qstr.length() > 1 && qstr.startsWith("\"") &&
>> qstr.endsWith("\"")) {
>>>>       qstr = qstr.substring(1,qstr.length()-1);
>>>>   }
>>>>   String[] nvps = StringUtils.split(qstr, " ");
>>>>   for (int i = 0; i < nvps.length; i++) {
>>>>       String[] nv = StringUtils.split(nvps[i], ":");
>>>>       if (nv.length > 1) {
>>>>         if (nv[0].startsWith("+")) {
>>>>           q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
>> nv[1]),
>>>>             new AveragePayloadFunction(), false), Occur.MUST);
>>>>         } else {
>>>>           q.add(new PayloadTermQuery(new Term(nv[0], nv[1]),
>>>>             new AveragePayloadFunction(), false), Occur.SHOULD);
>>>>         }
>>>>       }
>>>>   }
>>>>   return q;
>>>> }
>>>> 
>>>> 
>>>> --
>>>> Bill Bell
>>>> billnbell@gmail.com
>>>> cell 720-256-8076
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> Bill Bell
>>> billnbell@gmail.com
>>> cell 720-256-8076
>> 
>> 
> 
> 
> -- 
> Bill Bell
> billnbell@gmail.com
> cell 720-256-8076


Re: PayloadTermQuery deprecated

Posted by William Bell <bi...@gmail.com>.
Alan,

Does this code look equivalent? And how do I change PayLoadScoreQuery to do
a Custom Similarity?

PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
AveragePayloadFunction());

@Override
public Query parse() throws SyntaxError {

    if (qstr == null || qstr.length() == 0) return null;
    //BooleanQuery q = new BooleanQuery();
    BooleanQuery.Builder q = new BooleanQuery.Builder();
    q.setDisableCoord(true);
    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
        qstr = qstr.substring(1,qstr.length()-1);
    }
    String[] nvps = StringUtils.split(qstr, " ");
    for (int i = 0; i < nvps.length; i++) {
        String[] nv = StringUtils.split(nvps[i], ":");
        if (nv.length > 1) {
          if (nv[0].startsWith("+")) {
              SpanTermQuery sq = new SpanTermQuery(new
Term(nv[0].substring(1), nv[1]));
              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
AveragePayloadFunction());
              q.add(psq, Occur.MUST);
            //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
          } else {
            //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
AveragePayloadFunction(), false), Occur.SHOULD);
              SpanTermQuery sq = new SpanTermQuery(new Term(nv[0], nv[1]));
              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
AveragePayloadFunction());
              q.add(psq, Occur.SHOULD);
          }
        }
    }
    // return q;
    return q.build();
}


On Mon, Oct 19, 2015 at 1:49 AM, Alan Woodward <al...@flax.co.uk> wrote:

> Hi Bill,
>
> This looks like an oversight on my part when migrating the payload scoring
> queries - can you open a JIRA ticket to add 'includeSpanScore' as an option
> to PayloadScoreQuery?
>
> As a workaround, you should be able to use a custom similarity that
> returns 1 for all scores (see IndexSearcher.NON_SCORING_SIMILARITY for an
> implementation that returns 0, you could just clone that and change
> SimScorer.score())
>
> Alan Woodward
> www.flax.co.uk
>
>
> On 19 Oct 2015, at 00:39, William Bell wrote:
>
> > Here is my first stab at it. Thoughts?
> >
> > Question:
> >
> > new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]), new
> > AveragePayloadFunction(), false)
> >
> > How do I handle the "false"  ? It means boolean includeSpanScore
> >
> >
> > @Override
> > public Query parse() throws SyntaxError {
> >
> >    if (qstr == null || qstr.length() == 0) return null;
> >    //BooleanQuery q = new BooleanQuery();
> >    BooleanQuery.Builder q = new BooleanQuery.Builder();
> >    q.setDisableCoord(true);
> >    if (qstr.length() > 1 && qstr.startsWith("\"") &&
> qstr.endsWith("\"")) {
> >        qstr = qstr.substring(1,qstr.length()-1);
> >    }
> >    String[] nvps = StringUtils.split(qstr, " ");
> >    for (int i = 0; i < nvps.length; i++) {
> >        String[] nv = StringUtils.split(nvps[i], ":");
> >        if (nv.length > 1) {
> >          if (nv[0].startsWith("+")) {
> >              SpanTermQuery sq = new SpanTermQuery(new
> > Term(nv[0].substring(1), nv[1]));
> >              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> > AveragePayloadFunction());
> >              q.add(psq, Occur.MUST);
> >            //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
> > nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
> >          } else {
> >            //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
> > AveragePayloadFunction(), false), Occur.SHOULD);
> >              SpanTermQuery sq = new SpanTermQuery(new Term(nv[0],
> nv[1]));
> >              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> > AveragePayloadFunction());
> >              q.add(psq, Occur.SHOULD);
> >          }
> >        }
> >    }
> >    // return q;
> >    return q.build();
> > }
> >
> >
> > On Sun, Oct 18, 2015 at 4:46 PM, William Bell <bi...@gmail.com>
> wrote:
> >
> >> Wondering how to change my payload based on example:
> >>
> >>
> https://lucidworks.com/blog/2014/06/13/end-to-end-payload-example-in-solr/
> >>
> >> PayloadTermQuery and BooleanQuery are deprecated in 5.3.x
> >>
> >> @Override
> >> public Query parse() throws SyntaxError {
> >>
> >>    if (qstr == null || qstr.length() == 0) return null;
> >>    BooleanQuery q = new BooleanQuery();
> >>    if (qstr.length() > 1 && qstr.startsWith("\"") &&
> qstr.endsWith("\"")) {
> >>        qstr = qstr.substring(1,qstr.length()-1);
> >>    }
> >>    String[] nvps = StringUtils.split(qstr, " ");
> >>    for (int i = 0; i < nvps.length; i++) {
> >>        String[] nv = StringUtils.split(nvps[i], ":");
> >>        if (nv.length > 1) {
> >>          if (nv[0].startsWith("+")) {
> >>            q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
> nv[1]),
> >>              new AveragePayloadFunction(), false), Occur.MUST);
> >>          } else {
> >>            q.add(new PayloadTermQuery(new Term(nv[0], nv[1]),
> >>              new AveragePayloadFunction(), false), Occur.SHOULD);
> >>          }
> >>        }
> >>    }
> >>    return q;
> >> }
> >>
> >>
> >> --
> >> Bill Bell
> >> billnbell@gmail.com
> >> cell 720-256-8076
> >>
> >
> >
> >
> > --
> > Bill Bell
> > billnbell@gmail.com
> > cell 720-256-8076
>
>


-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076

Re: PayloadTermQuery deprecated

Posted by Alan Woodward <al...@flax.co.uk>.
I opened https://issues.apache.org/jira/browse/LUCENE-6844

Alan Woodward
www.flax.co.uk


On 19 Oct 2015, at 08:49, Alan Woodward wrote:

> Hi Bill,
> 
> This looks like an oversight on my part when migrating the payload scoring queries - can you open a JIRA ticket to add 'includeSpanScore' as an option to PayloadScoreQuery?
> 
> As a workaround, you should be able to use a custom similarity that returns 1 for all scores (see IndexSearcher.NON_SCORING_SIMILARITY for an implementation that returns 0, you could just clone that and change SimScorer.score())
> 
> Alan Woodward
> www.flax.co.uk
> 
> 
> On 19 Oct 2015, at 00:39, William Bell wrote:
> 
>> Here is my first stab at it. Thoughts?
>> 
>> Question:
>> 
>> new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]), new
>> AveragePayloadFunction(), false)
>> 
>> How do I handle the "false"  ? It means boolean includeSpanScore
>> 
>> 
>> @Override
>> public Query parse() throws SyntaxError {
>> 
>>    if (qstr == null || qstr.length() == 0) return null;
>>    //BooleanQuery q = new BooleanQuery();
>>    BooleanQuery.Builder q = new BooleanQuery.Builder();
>>    q.setDisableCoord(true);
>>    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
>>        qstr = qstr.substring(1,qstr.length()-1);
>>    }
>>    String[] nvps = StringUtils.split(qstr, " ");
>>    for (int i = 0; i < nvps.length; i++) {
>>        String[] nv = StringUtils.split(nvps[i], ":");
>>        if (nv.length > 1) {
>>          if (nv[0].startsWith("+")) {
>>              SpanTermQuery sq = new SpanTermQuery(new
>> Term(nv[0].substring(1), nv[1]));
>>              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
>> AveragePayloadFunction());
>>              q.add(psq, Occur.MUST);
>>            //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
>> nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
>>          } else {
>>            //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
>> AveragePayloadFunction(), false), Occur.SHOULD);
>>              SpanTermQuery sq = new SpanTermQuery(new Term(nv[0], nv[1]));
>>              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
>> AveragePayloadFunction());
>>              q.add(psq, Occur.SHOULD);
>>          }
>>        }
>>    }
>>    // return q;
>>    return q.build();
>> }
>> 
>> 
>> On Sun, Oct 18, 2015 at 4:46 PM, William Bell <bi...@gmail.com> wrote:
>> 
>>> Wondering how to change my payload based on example:
>>> 
>>> https://lucidworks.com/blog/2014/06/13/end-to-end-payload-example-in-solr/
>>> 
>>> PayloadTermQuery and BooleanQuery are deprecated in 5.3.x
>>> 
>>> @Override
>>> public Query parse() throws SyntaxError {
>>> 
>>>    if (qstr == null || qstr.length() == 0) return null;
>>>    BooleanQuery q = new BooleanQuery();
>>>    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
>>>        qstr = qstr.substring(1,qstr.length()-1);
>>>    }
>>>    String[] nvps = StringUtils.split(qstr, " ");
>>>    for (int i = 0; i < nvps.length; i++) {
>>>        String[] nv = StringUtils.split(nvps[i], ":");
>>>        if (nv.length > 1) {
>>>          if (nv[0].startsWith("+")) {
>>>            q.add(new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]),
>>>              new AveragePayloadFunction(), false), Occur.MUST);
>>>          } else {
>>>            q.add(new PayloadTermQuery(new Term(nv[0], nv[1]),
>>>              new AveragePayloadFunction(), false), Occur.SHOULD);
>>>          }
>>>        }
>>>    }
>>>    return q;
>>> }
>>> 
>>> 
>>> --
>>> Bill Bell
>>> billnbell@gmail.com
>>> cell 720-256-8076
>>> 
>> 
>> 
>> 
>> -- 
>> Bill Bell
>> billnbell@gmail.com
>> cell 720-256-8076
> 


Re: PayloadTermQuery deprecated

Posted by Alan Woodward <al...@flax.co.uk>.
Hi Bill,

This looks like an oversight on my part when migrating the payload scoring queries - can you open a JIRA ticket to add 'includeSpanScore' as an option to PayloadScoreQuery?

As a workaround, you should be able to use a custom similarity that returns 1 for all scores (see IndexSearcher.NON_SCORING_SIMILARITY for an implementation that returns 0, you could just clone that and change SimScorer.score())

Alan Woodward
www.flax.co.uk


On 19 Oct 2015, at 00:39, William Bell wrote:

> Here is my first stab at it. Thoughts?
> 
> Question:
> 
> new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]), new
> AveragePayloadFunction(), false)
> 
> How do I handle the "false"  ? It means boolean includeSpanScore
> 
> 
> @Override
> public Query parse() throws SyntaxError {
> 
>    if (qstr == null || qstr.length() == 0) return null;
>    //BooleanQuery q = new BooleanQuery();
>    BooleanQuery.Builder q = new BooleanQuery.Builder();
>    q.setDisableCoord(true);
>    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
>        qstr = qstr.substring(1,qstr.length()-1);
>    }
>    String[] nvps = StringUtils.split(qstr, " ");
>    for (int i = 0; i < nvps.length; i++) {
>        String[] nv = StringUtils.split(nvps[i], ":");
>        if (nv.length > 1) {
>          if (nv[0].startsWith("+")) {
>              SpanTermQuery sq = new SpanTermQuery(new
> Term(nv[0].substring(1), nv[1]));
>              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> AveragePayloadFunction());
>              q.add(psq, Occur.MUST);
>            //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
> nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
>          } else {
>            //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
> AveragePayloadFunction(), false), Occur.SHOULD);
>              SpanTermQuery sq = new SpanTermQuery(new Term(nv[0], nv[1]));
>              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
> AveragePayloadFunction());
>              q.add(psq, Occur.SHOULD);
>          }
>        }
>    }
>    // return q;
>    return q.build();
> }
> 
> 
> On Sun, Oct 18, 2015 at 4:46 PM, William Bell <bi...@gmail.com> wrote:
> 
>> Wondering how to change my payload based on example:
>> 
>> https://lucidworks.com/blog/2014/06/13/end-to-end-payload-example-in-solr/
>> 
>> PayloadTermQuery and BooleanQuery are deprecated in 5.3.x
>> 
>> @Override
>> public Query parse() throws SyntaxError {
>> 
>>    if (qstr == null || qstr.length() == 0) return null;
>>    BooleanQuery q = new BooleanQuery();
>>    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
>>        qstr = qstr.substring(1,qstr.length()-1);
>>    }
>>    String[] nvps = StringUtils.split(qstr, " ");
>>    for (int i = 0; i < nvps.length; i++) {
>>        String[] nv = StringUtils.split(nvps[i], ":");
>>        if (nv.length > 1) {
>>          if (nv[0].startsWith("+")) {
>>            q.add(new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]),
>>              new AveragePayloadFunction(), false), Occur.MUST);
>>          } else {
>>            q.add(new PayloadTermQuery(new Term(nv[0], nv[1]),
>>              new AveragePayloadFunction(), false), Occur.SHOULD);
>>          }
>>        }
>>    }
>>    return q;
>> }
>> 
>> 
>> --
>> Bill Bell
>> billnbell@gmail.com
>> cell 720-256-8076
>> 
> 
> 
> 
> -- 
> Bill Bell
> billnbell@gmail.com
> cell 720-256-8076


Re: PayloadTermQuery deprecated

Posted by William Bell <bi...@gmail.com>.
Here is my first stab at it. Thoughts?

Question:

new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]), new
AveragePayloadFunction(), false)

How do I handle the "false"  ? It means boolean includeSpanScore


@Override
public Query parse() throws SyntaxError {

    if (qstr == null || qstr.length() == 0) return null;
    //BooleanQuery q = new BooleanQuery();
    BooleanQuery.Builder q = new BooleanQuery.Builder();
    q.setDisableCoord(true);
    if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
        qstr = qstr.substring(1,qstr.length()-1);
    }
    String[] nvps = StringUtils.split(qstr, " ");
    for (int i = 0; i < nvps.length; i++) {
        String[] nv = StringUtils.split(nvps[i], ":");
        if (nv.length > 1) {
          if (nv[0].startsWith("+")) {
              SpanTermQuery sq = new SpanTermQuery(new
Term(nv[0].substring(1), nv[1]));
              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
AveragePayloadFunction());
              q.add(psq, Occur.MUST);
            //q.add(new PayloadTermQuery(new Term(nv[0].substring(1),
nv[1]), new AveragePayloadFunction(), false), Occur.MUST);
          } else {
            //q.add(new PayloadTermQuery(new Term(nv[0], nv[1]), new
AveragePayloadFunction(), false), Occur.SHOULD);
              SpanTermQuery sq = new SpanTermQuery(new Term(nv[0], nv[1]));
              PayloadScoreQuery psq = new PayloadScoreQuery(sq, new
AveragePayloadFunction());
              q.add(psq, Occur.SHOULD);
          }
        }
    }
    // return q;
    return q.build();
}


On Sun, Oct 18, 2015 at 4:46 PM, William Bell <bi...@gmail.com> wrote:

> Wondering how to change my payload based on example:
>
> https://lucidworks.com/blog/2014/06/13/end-to-end-payload-example-in-solr/
>
> PayloadTermQuery and BooleanQuery are deprecated in 5.3.x
>
> @Override
> public Query parse() throws SyntaxError {
>
>     if (qstr == null || qstr.length() == 0) return null;
>     BooleanQuery q = new BooleanQuery();
>     if (qstr.length() > 1 && qstr.startsWith("\"") && qstr.endsWith("\"")) {
>         qstr = qstr.substring(1,qstr.length()-1);
>     }
>     String[] nvps = StringUtils.split(qstr, " ");
>     for (int i = 0; i < nvps.length; i++) {
>         String[] nv = StringUtils.split(nvps[i], ":");
>         if (nv.length > 1) {
>           if (nv[0].startsWith("+")) {
>             q.add(new PayloadTermQuery(new Term(nv[0].substring(1), nv[1]),
>               new AveragePayloadFunction(), false), Occur.MUST);
>           } else {
>             q.add(new PayloadTermQuery(new Term(nv[0], nv[1]),
>               new AveragePayloadFunction(), false), Occur.SHOULD);
>           }
>         }
>     }
>     return q;
> }
>
>
> --
> Bill Bell
> billnbell@gmail.com
> cell 720-256-8076
>



-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076