TSVectorPGEncoding returns the PG-compatible wire protocol encoding for a given weight. Note that this is only allowable for TSVector tsweights, which can't have more than one weight set at the same time. In a TSQuery, you might have more than one weight per lexeme, which is not encodable using this
()
| 103 | // have more than one weight per lexeme, which is not encodable using this |
| 104 | // scheme. |
| 105 | func (w tsWeight) TSVectorPGEncoding() (byte, error) { |
| 106 | switch w { |
| 107 | case weightA: |
| 108 | return 3, nil |
| 109 | case weightB: |
| 110 | return 2, nil |
| 111 | case weightC: |
| 112 | return 1, nil |
| 113 | case weightD, 0: |
| 114 | return 0, nil |
| 115 | } |
| 116 | return 0, errors.Errorf("invalid tsvector weight %d", w) |
| 117 | } |
| 118 | |
| 119 | func (w tsWeight) val() int { |
| 120 | b, err := w.TSVectorPGEncoding() |
no test coverage detected