2017-03-21 2 views
1

저는 Solr에 대해 배우고 있으며 문제가 있습니다. Solr에게 다음과 같이 쿼리를 작성하면 :콘텐츠 유형 Solr 응답

curl "http://localhost:8983/solr/myCollection/select?q=*:*&wt=json&rows=0" 

JSON 응답이있는 웹 페이지가 나타납니다. 그러나 웹 페이지 헤더에는 Content-Type에 대한 내용이 없습니다.

Solr을 쿼리하는 사람들이 Solr 응답을 정리하고 "들여 쓰기 = 켜짐"옵션을 제공하지 않고도 읽기 쉽도록 예쁜 인쇄 도구를 사용할 수 있도록 Content-Type을 헤더에 넣고 싶습니다. 시각.

어떤 도움이 필요합니까?

감사

<html> 
    <head> 
    <link rel="alternate stylesheet" type="text/css" 
    href="resource://gre-resources/plaintext.css" 
    title="Wrap Long Lines"> 
    <style type="text/css"></style> 
    </head> 
    <body> 
    <pre>{"responseHeader":{"status":0,"QTime":0,"params": 
     {"q":"*:*","rows":"0","wt":"json"}},"response": 
     {"numFound":27394430,"start":0,"docs":[]}} 
    </pre> 
    </body> 
</html> 

편집

: 아래의 답변 덕분에, 나는 그것을 고정되었다. 나는 구성 API를 사용하여 변경 한 : 변경 사항을 표시 할 수있는 분을 기다려야 할 수 있도록

curl http://localhost:8983/solr/collectionName/config 
    -H 'Content-Type:application/json' -d '{ 
    "update-queryresponsewriter" : { 
    "name":"json", 
    "class":"solr.JSONResponseWriter", 
    "defaults": { 
     "name":"application/json; charset=UTF-8" 
    } 
    } 
}' 

그냥 참고로, 변화는, 나를 위해 즉시 적용되지 않았다. 그것은 일반 텍스트 것처럼 당신이보고 싶어하지 않는, 그래서 JSON 뷰어없이

<queryResponseWriter name="json" class="solr.JSONResponseWriter"> 
    <!-- For the purposes of the tutorial, JSON responses are written as 
    plain text so that they are easy to read in *any* browser. 
    If you expect a MIME type of "application/json" just remove this override. 
    --> 
    <str name="content-type">text/plain; charset=UTF-8</str> 
    </queryResponseWriter> 

현대 브라우저, JSON을 표시합니다

답변