When I look at the Solr source code, if I’m understanding correctly, it’s not 
possible to get CSV formatted response from the terms handler. Because terms 
handler puts its data in “terms” key of the map while CSVWriter reads data from 
the “response” key only.

//org.apache.solr.handler.component.TermsComponent line:412
public void finishStage(ResponseBuilder rb) {
        ...
        ...
        //"rsp" is the SolrQueryResponse object
        rb.rsp.add("terms", terms);
        ...
        ...
}

//org.apache.solr.response.CSVWriter line:372
         ...
       writeResponse(rsp.getResponse());

//org.apache.solr.response.SolrQueryResponse
        private static final String RESPONSE_KEY = "response";
        ...
        ...
        /** Return response */
        public Object getResponse() {
                return values.get(RESPONSE_KEY);
        }

--ufuk

Sent from Mail for Windows

From: Moriyasu Kannami
Sent: Friday, September 29, 2023 4:19 PM
To: us...@solr.apache.org
Subject: Re: Solr9 TermsComponent behavior that response writer is csv

Hi ufuk,

Thank you for your reply.
I'll check & try, then report here.

Regards,
mori.


2023年9月29日(金) 20:35 ufuk yılmaz <uyil...@vivaldi.net.invalid>:
>
> Hello,
>
> Did you try specifying different values for csv.separator or csv.encapsulator 
> parameters? Try to choose some unusual characters  which can’t exist in terms 
> themselves. 
> https://solr.apache.org/guide/solr/latest/query-guide/response-writers.html#csv-response-writer
>
> My first guess is it’s encountering some error while building the rows and 
> just swallowing the error instead of throwing an exception or an error 
> message.
>
> Regards
>
> ~Ufuk Yilmaz
>
> Sent from Mail for Windows
>
> From: Moriyasu Kannami
> Sent: Friday, September 29, 2023 1:12 PM
> To: us...@solr.apache.org
> Subject: Solr9 TermsComponent behavior that response writer is csv
>
> Hi,
>
> I'm using Solr 9.3.0(Java 11).
>
> About TermsComponent.
> When specifying JSON or XML with wt parameter, the expected response
> is returned.
> But when specifying CSV, only all field names are returned. No data is 
> returned.
> What is the solution to this problem?
>
>  DATA's
> - URL
> https://xxxx/solr/instance_name/terms?terms=true&terms.fl=body&terms.limit=1000&terms.sort=count&wt=csv
> - Field definitions in managed_schema
> <field name="_root_" type="string" indexed="true" stored="false"/>
> <field name="_version_" type="long" indexed="false" stored="false"
> docValues="true"/>
> <field name="id" type="string" indexed="true" stored="true"
> required="true" multiValued="false" />
> <field name="keyphrase" type="string" multiValued="true"
> indexed="true" stored="true"/>
> <field name="category" type="string" indexed="true" stored="true"
> docValues="true"/>
> <field name="date" type="date" indexed="true" stored="false"/>
> <field name="url" type="string" indexed="true" stored="true"
> multiValued="false"/>
> <field name="body" type="text_ja" indexed="true" stored="true"
> multiValued="true"/>
> <field name="body_exact" type="text_ja_exact" indexed="true"
> stored="true" multiValued="true"/>
> <field name="body_reading" type="text_ja_reading" indexed="true"
> stored="true" multiValued="true"/>
> <field name="body_2g" type="text_2g" indexed="true" stored="true"
> multiValued="true"/>
> <field name="body_2g_exact" type="text_2g_exact" indexed="true"
> stored="true" multiValued="true"/>
> <field name="body_hl_alternate" type="text_ja" multiValued="true"
> indexed="false" stored="true"/>
> <field name="text" type="text" multiValued="true" indexed="true"
> stored="false"/>
> <field name="text_rev" type="text_rev" multiValued="true"
> indexed="true" stored="false"/>
> <field name="title" type="text_ja" indexed="true" stored="true"/>
> <field name="title_exact" type="text_ja_exact" indexed="true" stored="true"/>
> <field name="title_2g" type="text_2g" indexed="true" stored="true"/>
> <field name="title_2g_exact" type="text_2g_exact" indexed="true" 
> stored="true"/>
> <field name="body_disease" type="string" indexed="true" stored="true"
> multiValued="true"/>
> <field name="body_facility" type="string" indexed="true" stored="true"
> multiValued="true"/>
> - Response(Unexpected)
> date,title_exact,body_reading,title_2g_exact,title,body,url,body_2g_exact,body_2g,_version_,title_2g,body_exact,body_hl_alternate,id,category
>
> Regards,
> mori.
>

Reply via email to