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

Aibao Luo updated SOLR-11885:
-----------------------------
    Description: 
public Map<String,LBHttpSolrClient.Req> getRoutes(DocRouter router, 
DocCollection col, Map<String,List<String>> urlMap, ModifiableSolrParams 
params, String idField) {

 ....
 if (request != null) {

  UpdateRequest urequest = (UpdateRequest) request.getRequest();

  urequest.deleteById(deleteId, version);

} else {

  UpdateRequest urequest = new UpdateRequest();

  urequest.setParams(params);

  urequest.deleteById(deleteId, version);

  urequest.setCommitWithin(getCommitWithin());

  request = new LBHttpSolrClient.Req(urequest, urls);

  routes.put(leaderUrl, request);

}

....

}

 

while delete by ids, inner wrapped request to routed slice should contains  
auth credentials from source request, as adding documents does.

  was:
public Map<String,LBHttpSolrClient.Req> getRoutes(DocRouter router,
 DocCollection col, Map<String,List<String>> urlMap,
 ModifiableSolrParams params, String idField) {
 
 if ((documents == null || documents.size() == 0)
 && (deleteById == null || deleteById.size() == 0)) {
 return null;
 }
 
 Map<String,LBHttpSolrClient.Req> routes = new HashMap<>();
 if (documents != null) {
 Set<Entry<SolrInputDocument,Map<String,Object>>> entries = 
documents.entrySet();
 for (Entry<SolrInputDocument,Map<String,Object>> entry : entries) {
 SolrInputDocument doc = entry.getKey();
 Object id = doc.getFieldValue(idField);
 if (id == null) {
 return null;
 }
 Slice slice = router.getTargetSlice(id
 .toString(), doc, null, null, col);
 if (slice == null) {
 return null;
 }
 List<String> urls = urlMap.get(slice.getName());
 if (urls == null) {
 return null;
 }
 String leaderUrl = urls.get(0);
 LBHttpSolrClient.Req request = (LBHttpSolrClient.Req) routes
 .get(leaderUrl);
 if (request == null) {
 UpdateRequest updateRequest = new UpdateRequest();
 updateRequest.setMethod(getMethod());
 updateRequest.setCommitWithin(getCommitWithin());
 updateRequest.setParams(params);
 updateRequest.setPath(getPath());
 updateRequest.setBasicAuthCredentials(getBasicAuthUser(), 
getBasicAuthPassword());
 request = new LBHttpSolrClient.Req(updateRequest, urls);
 routes.put(leaderUrl, request);
 }
 UpdateRequest urequest = (UpdateRequest) request.getRequest();
 Map<String,Object> value = entry.getValue();
 Boolean ow = null;
 if (value != null) {
 ow = (Boolean) value.get(OVERWRITE);
 }
 if (ow != null) {
 urequest.add(doc, ow);
 } else {
 urequest.add(doc);
 }
 }
 }
 
 // Route the deleteById's
 
 if (deleteById != null) {
 
 Iterator<Map.Entry<String,Map<String,Object>>> entries = deleteById.entrySet()
 .iterator();
 while (entries.hasNext()) {
 
 Map.Entry<String,Map<String,Object>> entry = entries.next();
 
 String deleteId = entry.getKey();
 Map<String,Object> map = entry.getValue();
 Long version = null;
 if (map != null) {
 version = (Long) map.get(VER);
 }
 Slice slice = router.getTargetSlice(deleteId, null, null, null, col);
 if (slice == null) {
 return null;
 }
 List<String> urls = urlMap.get(slice.getName());
 if (urls == null) {
 return null;
 }
 String leaderUrl = urls.get(0);
 LBHttpSolrClient.Req request = routes.get(leaderUrl);
 if (request != null) {
 UpdateRequest urequest = (UpdateRequest) request.getRequest();
 urequest.deleteById(deleteId, version);
 } else {
 UpdateRequest urequest = new UpdateRequest();
 urequest.setParams(params);
 urequest.deleteById(deleteId, version);
 urequest.setCommitWithin(getCommitWithin());
 request = new LBHttpSolrClient.Req(urequest, urls);
 routes.put(leaderUrl, request);
 }
 }
 }

 return routes;
}

 

when call delete by ids, inner wrapped request to routed slice should contains  
auth credentials from source request, as adding documents does.


> Solrj client deleteByIds handle route request miss wrap basic auth credentials
> ------------------------------------------------------------------------------
>
>                 Key: SOLR-11885
>                 URL: https://issues.apache.org/jira/browse/SOLR-11885
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: SolrJ
>    Affects Versions: 5.5.5, 6.6.2, 7.2.1
>            Reporter: Aibao Luo
>            Priority: Major
>
> public Map<String,LBHttpSolrClient.Req> getRoutes(DocRouter router, 
> DocCollection col, Map<String,List<String>> urlMap, ModifiableSolrParams 
> params, String idField) {
>  ....
>  if (request != null) {
>   UpdateRequest urequest = (UpdateRequest) request.getRequest();
>   urequest.deleteById(deleteId, version);
> } else {
>   UpdateRequest urequest = new UpdateRequest();
>   urequest.setParams(params);
>   urequest.deleteById(deleteId, version);
>   urequest.setCommitWithin(getCommitWithin());
>   request = new LBHttpSolrClient.Req(urequest, urls);
>   routes.put(leaderUrl, request);
> }
> ....
> }
>  
> while delete by ids, inner wrapped request to routed slice should contains  
> auth credentials from source request, as adding documents does.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to