[
https://issues.apache.org/jira/browse/SOLR-11865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420858#comment-16420858
]
David Smiley commented on SOLR-11865:
-------------------------------------
Thanks for the update; it's looking nicer. The delta patch was helpful
(thanks!) but "Yetus" didn't know what to make of it. The SOLR-XXXX.patch file
should be a standard diff or git formap-patch. The one I see right now is
definitely not that; it's only 2 lines.
(getBoostDocs):
bq. 6- Use localBoosts.addAll(boosted.keySet()); at line ~661 instead of manual
looping.
I believe the "localBoosts" var is a copy intentionally because the algorithm
that follows will remove items to reduce the lookups in 1/2. See
{{iter.remove()}}. In your recent change, you're manipulating the incoming
argument from the parameter (not good).
I propose the following rewrite of this method. Whoever first wrote it didn't
know about {{SolrIndexSearcher.lookupId(...)}}.
{code:java}
public static IntIntHashMap getBoostDocs(SolrIndexSearcher indexSearcher,
Map<BytesRef, Integer>boosted, Map context) throws IOException {
IntIntHashMap boostDocs = null;
if(boosted != null) {
//First see if it's already in the request context. Could have been put
there
//by another caller.
if(context != null) {
boostDocs = (IntIntHashMap) context.get(BOOSTED_DOCIDS);
}
if(boostDocs != null) {
return boostDocs;
}
//Not in the context yet so load it.
boostDocs = new IntIntHashMap(boosted.size()); // docId to boost
for (Map.Entry<BytesRef,Integer> keyAndBoostPair : boosted.entrySet()) {
final BytesRef uniqueKey = keyAndBoostPair.getKey();
long segAndId = indexSearcher.lookupId(uniqueKey); // higher 32 bits ==
segment ID, low 32 bits == doc ID
if (segAndId == -1) { // not found
continue;
}
int seg = (int) (segAndId >> 32);
int localDocId = (int) segAndId;
final IndexReaderContext indexReaderContext =
indexSearcher.getTopReaderContext().children().get(seg);
int docId = indexReaderContext.docBaseInParent + localDocId;
boostDocs.put(docId, keyAndBoostPair.getValue());
}
}
if(context != null) {
//noinspection unchecked
context.put(BOOSTED_DOCIDS, boostDocs);
}
return boostDocs;
}
{code}
I'll respond to the other parts in another comment.
> Refactor QueryElevationComponent to prepare query subset matching
> -----------------------------------------------------------------
>
> Key: SOLR-11865
> URL: https://issues.apache.org/jira/browse/SOLR-11865
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Components: SearchComponents - other
> Affects Versions: master (8.0)
> Reporter: Bruno Roustant
> Priority: Minor
> Labels: QueryComponent
> Fix For: master (8.0)
>
> Attachments:
> 0001-Refactor-QueryElevationComponent-to-introduce-Elevat.patch,
> 0002-Refactor-QueryElevationComponent-after-review.patch, SOLR-11865.patch
>
>
> The goal is to prepare a second improvement to support query terms subset
> matching or query elevation rules.
> Before that, we need to refactor the QueryElevationComponent. We make it
> extendible. We introduce the ElevationProvider interface which will be
> implemented later in a second patch to support subset matching. The current
> full-query match policy becomes a default simple MapElevationProvider.
> - Add overridable methods to handle exceptions during the component
> initialization.
> - Add overridable methods to provide the default values for config properties.
> - No functional change beyond refactoring.
> - Adapt unit test.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]