2013-03-11 16 views

cevap

7

Bu konu için ClientUtils.toQueryString'u öneririm. Buna, bu nedenle Solrj kodunun kendisi kullanıldığını görebilirsiniz HttpSolrServer kaynak kodunda

@Test 
public void solrQueryToURL() { 
    SolrQuery tmpQuery = new SolrQuery("some query"); 
    Assert.assertEquals("?q=some+query", ClientUtils.toQueryString(tmpQuery, false)); 
} 

.

public NamedList<Object> request(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { 

    // ... other code left out 

    if(SolrRequest.METHOD.GET == request.getMethod()) { 
    if(streams != null) { 
     throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "GET can't send streams!"); 
    } 
    method = new HttpGet(baseUrl + path + ClientUtils.toQueryString(params, false)); 

    // ... other code left out 

    } 
1

SolrJ (test edilen sürüm 6.6.0) o:

@Test 
public void solrQueryToURL() { 
    SolrQuery query = new SolrQuery("query"); 
    Assert.assertEquals("?q=query", query.toQueryString()); 
} 
İlgili konular