Hi Erick,

It seems I've reached a dead-point, or at least it seems looking at the
code, it seems I can't  easily add a custom decoder:

Looking at PayloadUtils class there is getPayloadDecoder method invoked to
return the PayloadDecoder :

  public static PayloadDecoder getPayloadDecoder(FieldType fieldType) {
    PayloadDecoder decoder = null;

    String encoder = getPayloadEncoder(fieldType);

    if ("integer".equals(encoder)) {
      decoder = (BytesRef payload) -> payload == null ? 1 :
PayloadHelper.decodeInt(payload.bytes, payload.offset);
    }
    if ("float".equals(encoder)) {
      decoder = (BytesRef payload) -> payload == null ? 1 :
PayloadHelper.decodeFloat(payload.bytes, payload.offset);
    }
    // encoder could be "identity" at this point, in the case of
DelimitedTokenFilterFactory encoder="identity"

    // TODO: support pluggable payload decoders?

    return decoder;
  }

Any advice to work around this situation?


On Mon, Oct 21, 2019 at 1:51 AM Erick Erickson <erickerick...@gmail.com>
wrote:

> You’d need to write one. Payloads are generally intended to hold numerics
> you can then use in a function query to factor into the score…
>
> Best,
> Erick
>
> > On Oct 20, 2019, at 4:57 PM, Vincenzo D'Amore <v.dam...@gmail.com>
> wrote:
> >
> > Sorry, I just realized that I was wrong in how I'm using the payload
> > function.
> > Give that the payload function only handles a numeric (integer or float)
> > payload, could you suggest me an alternative function that handles
> strings?
> > If not, should I write one?
> >
> > On Sun, Oct 20, 2019 at 10:43 PM Vincenzo D'Amore <v.dam...@gmail.com>
> > wrote:
> >
> >> Hi all,
> >>
> >> I'm trying to understand what I did wrong with a payload query that
> >> returns
> >>
> >> error: {
> >> metadata: [ "error-class", "org.apache.solr.common.SolrException",
> >> "root-error-class", "org.apache.solr.common.SolrException" ],
> >> msg: "No payload decoder found for field: colorCode",
> >> code: 400
> >> }
> >>
> >> I have reduced my problem in a little sample to show what happens to me.
> >> Basically I have a document with a couple of payload fields one
> >> delimited_payloads_string and one delimited_payloads_integer
> >>
> >> {
> >> field_dps: "key|data",
> >> field_dpi: "key|1",
> >> }
> >>
> >> When I execute this query solr returns as expected the payload for the
> key
> >>
> >> q=*:*&fl=payload(field_dpi,key)
> >>
> >> {
> >> payload(field_dpi,key): 1
> >> }
> >>
> >> But for the strings there have to be something of different to do,
> because
> >> I'm unable receive the payload value back. Executing this query, as in
> the
> >> short introduction of this post, I receive an error.
> >>
> >> ?q=*:*&fl=payload(field_dps,key)
> >>
> >> error: {
> >> metadata: [ "error-class", "org.apache.solr.common.SolrException",
> >> "root-error-class", "org.apache.solr.common.SolrException" ],
> >> msg: "No payload decoder found for field: colorCode",
> >> code: 400
> >> }
> >>
> >> Am I doing something wrong? How can I read strings payload data?
> >>
> >> Thanks in advance for your time,
> >> Vincenzo
> >>
> >> --
> >> Vincenzo D'Amore
> >>
> >>
> >
> > --
> > Vincenzo D'Amore
>
>

-- 
Vincenzo D'Amore

Reply via email to