lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Bell <billnb...@gmail.com>
Subject PayloadTermQuery deprecated
Date Sun, 18 Oct 2015 22:46:37 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message