Solr now smoothly integrates with Lucene-level payloads.
Payloads provide optional per-term metadata, numeric or otherwise. Payloads help solve challenging use cases such as per-store product pricing and per-term confidence/weighting.
This session will present the payload feature from the Lucene layer up to the Solr integration, including per-store pricing, per-term weighting, and more.
2. Solr now smoothly integrates with Lucene-level payloads.
Payloads provide optional per-term metadata, numeric or
otherwise. Payloads help solve challenging use cases such as
per-store product pricing and per-term confidence/weighting.
This session will present the payload feature from the Lucene
layer up to the Solr integration, including per-store pricing,
per-term weighting, and more.
Payloads in Solr
3. Payloads in Solr
01
tl;dr
• Solr 6.6+ via SOLR-1485
• per-term position metadata
• Use cases:
• per-store pricing
• weighting terms: e.g. confidence of
term, or importance/relevance of term
• weighting term types (synonyms
factor lower, verbs factor higher)
4. Payloads in Solr
01
Lucene’s Payloads
• Token: PayloadAttribute
• byte[] per term position, optional
• Several components set payloads
• Similarity.SimScorer
#computePayloadFactor
• No built-in components (outside
Lucene’s test cases), before
SOLR-1485, implemented this
• PostingsEnum#getPayload
17. Payloads in Solr
01
Solr Integration
• Schema-aware
• DelimitedPayloadTokenFilter:
• float, integer, identity
• NumericPayloadTokenFilter: float
• Function / Value Source
• payload()
• Query parsers
• {!payload_score}
• {!payload_check}
• Default (data_driven) schema has built-in payload-enabled
dynamic field mappings:
• *_dpf, *_dpi, and *_dps
18. Payloads in Solr
01
Solr features with payloads
• searching (scoring by payload):
q={!payload_score…}
• searching (filtering by payload):
fq={!frange cost=999 l=0 u=100}payload(…)
• sorting:
sort=payload(…) desc
• faceting:
facet.query={!frange
l=0 u=100
v=$payload_func}
&payload_func=payload(…)
19. Payloads in Solr
01
payload()
• payload(field,
term
[,default_value
[,min|max|average|first]])
• Operates on float or integer encoded payloads
• Value source, returning a single float per-document
• Multiple term matches are possible, returning the min,
max, or average. first is a special short-circuit
• If no term match for document, returns default value,
or zero
20. Payloads in Solr
01
payload() uses
• &payload_function=payload(….)
• Returning:
fl=payload_result:${payload_function}
• Sorting:
sort=${payload function} desc
• Range faceting:
facet.query={!frange
key=up_to_one_hundred
l=0 u=100 v=$payload_function}
• Matching:
• without payload considered: term query, eg {!term}
• with payloads factored: {!payload_check}
21. Payloads in Solr
01
{!payload_score}
• SpanQuery wrapping, payload-based scoring
• SpanQuery support: currently SpanNearQuery of
SpanTermQuery’s
• scoring:
• payload function: min, max, or average
• includeSpanScore=true: multiples payload
function result by base query scoring
• with a simple term query, payload() function is
equivalent (with includeSpanScore=false)
24. Payloads in Solr
01
{!payload_check}
• SpanQuery wrapping, phrase relevancy scoring
• SpanQuery support: currently SpanNearQuery of
SpanTermQuery’s
• matching:
• matches when all terms match all corresponding
payloads, in order
• scoring:
• uses SpanNearQuery’s score
26. Payloads in Solr
01
Payload Cons
• payload(): if used as a {!func} q or facet.query it will
compute value for ALL documents in index. To PostFilter fq
payload function computation of just matching documents use
{!frange} with payload()
• Updating values
• Atomic field update
• (could multivalue and delete/add a single term|value)?
• could mean updating all inventory for all stores for a single
change
• no current range faceting support (of functions in general)
27. Payloads in Solr
01
What’s next
• SOLR-10541 - “Range facet by function”
• solves range faceting by payload
• LUCENE-7854: term frequency “payload”
• coming soon, see SOLR-11358
• OpenNLP types => payloads
• Pluggable encoders/decoders?