lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dallan Quass (JIRA)" <j...@apache.org>
Subject [jira] Updated: (SOLR-1795) Subclassing QueryComponent for fetching results from a database
Date Thu, 25 Feb 2010 21:10:27 GMT

     [ https://issues.apache.org/jira/browse/SOLR-1795?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Dallan Quass updated SOLR-1795:
-------------------------------

    Description: 
This is a request to change the access on a few fields from package to public.

I've subclassed QueryComponent to allow me to fetch results from a database (based upon the
stored uniqueKey field) instead of from the shards. The only stored field in solr is the uniqueKey
field, and whatever fields I might need for sorting.  To do this I've overridden QueryComponent.finishStage
so that after executing the query, SolrDocuments are created with the uniqueKey field.  A
later component populates the rest of the fields in the documents by reading them from a database.

{code}
public void finishStage(ResponseBuilder rb) {
   if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
      // Create SolrDocument's from the ShardDoc's
      boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
      for (ShardDoc sdoc : rb.resultIds.values()) {
         SolrDocument doc = new SolrDocument();
         doc.setField("id", sdoc.id);
         if (returnScores && sdoc.score != null) {
            doc.setField("score", sdoc.score);
         }
         rb._responseDocs.set(sdoc.positionInResponse, doc);
      }
   }
}
{code}

Everything works fine, but ResponseBuilder variables: *resultIds* and *_responseDocs*, and
ShardDoc variables: *id*, *score*, and *positionInResponse* currently all have package visibility.
 I needed to modify the core solr files to change their visibility to public so that I could
access them in the function above. Is there any chance that they could be changed to public
in a future version of Solr, or somehow make them accessible outside the package?

If people are interested, I could post the QueryComponent subclass and database component
that I wrote. But it gets a bit involved because the QueryComponent subclass also handles
parsing the query just at the main solr server, and sending serialized parsed queries to the
shards.  (Query parsing in my environment is pretty cpu- and memory-intensive so I do it just
at the main server instead of the shards.)


  was:
This is a request to change the access on a few fields from package to public.

I've subclassed QueryComponent to allow me to fetch results from a database (based upon the
stored uniqueKey field) instead of from the shards. The only stored field in solr is the uniqueKey
field, and whatever fields I might need for sorting.  To do this I've overridden QueryComponent.finishStage
so that after executing the query, SolrDocuments are created with the uniqueKey field.  A
later component populates the rest of the fields in the documents by reading them from a database.

{code}
public void finishStage(ResponseBuilder rb) {
   if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
      // Create SolrDocument's from the ShardDoc's
      boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
      for (ShardDoc sdoc : rb.resultIds.values()) {
         SolrDocument doc = new SolrDocument();
         doc.setField(UNIQUE_KEY_FIELDNAME, sdoc.id);
         if (returnScores && sdoc.score != null) {
            doc.setField("score", sdoc.score);
         }
         rb._responseDocs.set(sdoc.positionInResponse, doc);
      }
   }
}
{code}

Everything works fine, but ResponseBuilder variables: *resultIds* and *_responseDocs*, and
ShardDoc variables: *id*, *score*, and *positionInResponse* currently all have package visibility.
 I needed to modify the core solr files to change their visibility to public so that I could
access them in the function above. Is there any chance that they could be changed to public
in a future version of Solr, or somehow make them accessible outside the package?

If people are interested, I could post the QueryComponent subclass and database component
that I wrote. But it gets a bit involved because the QueryComponent subclass also handles
parsing the query just at the main solr server, and sending serialized parsed queries to the
shards.  (Query parsing in my environment is pretty cpu- and memory-intensive so I do it just
at the main server instead of the shards.)



> Subclassing QueryComponent for fetching results from a database
> ---------------------------------------------------------------
>
>                 Key: SOLR-1795
>                 URL: https://issues.apache.org/jira/browse/SOLR-1795
>             Project: Solr
>          Issue Type: Improvement
>          Components: SearchComponents - other
>    Affects Versions: 1.4
>            Reporter: Dallan Quass
>
> This is a request to change the access on a few fields from package to public.
> I've subclassed QueryComponent to allow me to fetch results from a database (based upon
the stored uniqueKey field) instead of from the shards. The only stored field in solr is the
uniqueKey field, and whatever fields I might need for sorting.  To do this I've overridden
QueryComponent.finishStage so that after executing the query, SolrDocuments are created with
the uniqueKey field.  A later component populates the rest of the fields in the documents
by reading them from a database.
> {code}
> public void finishStage(ResponseBuilder rb) {
>    if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
>       // Create SolrDocument's from the ShardDoc's
>       boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES)
!= 0;
>       for (ShardDoc sdoc : rb.resultIds.values()) {
>          SolrDocument doc = new SolrDocument();
>          doc.setField("id", sdoc.id);
>          if (returnScores && sdoc.score != null) {
>             doc.setField("score", sdoc.score);
>          }
>          rb._responseDocs.set(sdoc.positionInResponse, doc);
>       }
>    }
> }
> {code}
> Everything works fine, but ResponseBuilder variables: *resultIds* and *_responseDocs*,
and ShardDoc variables: *id*, *score*, and *positionInResponse* currently all have package
visibility.  I needed to modify the core solr files to change their visibility to public so
that I could access them in the function above. Is there any chance that they could be changed
to public in a future version of Solr, or somehow make them accessible outside the package?
> If people are interested, I could post the QueryComponent subclass and database component
that I wrote. But it gets a bit involved because the QueryComponent subclass also handles
parsing the query just at the main solr server, and sending serialized parsed queries to the
shards.  (Query parsing in my environment is pretty cpu- and memory-intensive so I do it just
at the main server instead of the shards.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message