[ 
https://issues.apache.org/jira/browse/SOLR-8220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15068319#comment-15068319
 ] 

Erick Erickson commented on SOLR-8220:
--------------------------------------

bq: For the DocValues.getDocsWithField(atomicReader, fieldName).get(docid), not 
having it was resulting in empty fields being returned for documents that 
weren't supposed to have an docValue (the user never added a docValue for that 
document during indexing).

Right, I had to add a test at the end to avoid that. I didn't track the code 
thoroughly, but does the DocValues.getDocsWithField allocate a BitSet or just 
return a pre-existing instance? Or even cache the BitSet somewhere? If it 
allocates a new BitSet (or even fills up a cache entry), the test at the end 
might be much less expensive. I didn't track it down though, and if it returns 
a reference to a cached bitset that will be created _anyway_, then it's just a 
style thing....

{code}
 if (outValues.size() > 0) {
   sdoc.addField()....
}
{code}

As for whether the loop returns all values in the field, I saw this "by 
inspection" on the techproducts example (with a few mods for adding 
docValues="true" to the schema). Again, though, this is 4.x after I hacked a 
backport and put it in an entirely different place in the code, specifically 
NOT a visitor pattern. So it's entirely possible that the semantics have 
changed or hacking it into a different part of the code base has a different 
context.  A test would settle it for all time though.

> Read field from docValues for non stored fields
> -----------------------------------------------
>
>                 Key: SOLR-8220
>                 URL: https://issues.apache.org/jira/browse/SOLR-8220
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Keith Laban
>         Attachments: SOLR-8220-5x.patch, SOLR-8220-ishan.patch, 
> SOLR-8220-ishan.patch, SOLR-8220-ishan.patch, SOLR-8220-ishan.patch, 
> SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, 
> SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, 
> SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, 
> SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, SOLR-8220.patch, 
> SOLR-8220.patch, SOLR-8220.patch
>
>
> Many times a value will be both stored="true" and docValues="true" which 
> requires redundant data to be stored on disk. Since reading from docValues is 
> both efficient and a common practice (facets, analytics, streaming, etc), 
> reading values from docValues when a stored version of the field does not 
> exist would be a valuable disk usage optimization.
> The only caveat with this that I can see would be for multiValued fields as 
> they would always be returned sorted in the docValues approach. I believe 
> this is a fair compromise.
> I've done a rough implementation for this as a field transform, but I think 
> it should live closer to where stored fields are loaded in the 
> SolrIndexSearcher.
> Two open questions/observations:
> 1) There doesn't seem to be a standard way to read values for docValues, 
> facets, analytics, streaming, etc, all seem to be doing their own ways, 
> perhaps some of this logic should be centralized.
> 2) What will the API behavior be? (Below is my proposed implementation)
> Parameters for fl:
> - fl="docValueField"
>   -- return field from docValue if the field is not stored and in docValues, 
> if the field is stored return it from stored fields
> - fl="*"
>   -- return only stored fields
> - fl="+"
>    -- return stored fields and docValue fields
> 2a - would be easiest implementation and might be sufficient for a first 
> pass. 2b - is current behavior



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to