How to override responseWriter value
I need to override the default value of responseWiter in Query annotation. The default value is javabin. But the solr server is expecting wt=json. Eg -
org.apache.solr.core.SolrCore: [ac_shard1_replica2] webapp=/solr path=/suggest_keyword params={fl=keyword,user_count&sort=user_count+desc&indent=true&q=jea&wt=json&rows=5} hits=14 status=0 QTime=1
But when I am using @Query the generate log is - org.apache.solr.core.SolrCore: [ac_shard1_replica2] webapp=/solr path=/suggest_keyword params={start=0&q=keyword:app&wt=javabin&qt=/suggest_keyword&version=2&rows=0} hits=0 status=0 QTime=1
And solr server returning some html file to this but the json response. How can I set the value to json instead of javabin ??
Thanks in advance.
SolrJ is designed for the javabin format though you can handle json with some tweaks as you need to have a SolrResponse capable of reading that particular format. Please have a look at SolrJsonRequest.
Thanks for the response. What I understood after reading about javabin is that there is no need to convert the response to json as javabin should get converted to pojo automatically. But somehow that is not happening and I am not sure how to debug that.
My pojo is like - @SolrDocument(solrCoreName = "ac") public class Keyword {
@Id
@Indexed("keyword")
private String keyword;
@Indexed("user_count")
private String user_count;
@Indexed("recommendation")
private String recommendation;
@Indexed("suggest")
private String suggest;
@Indexed("suggest_ngram")
private String suggest_ngram;
@Indexed("_version_")
private String _version_;
//getter and setters,,,,// }
And Repository -
interface ProductRepository extends SolrCrudRepository<Keyword, String> {
@Query(fields = {"keyword","user_count","recommendation","suggest","suggest_ngram","_version_"} ,requestHandler = "/suggest_keyword", defaultOperator = Operator.AND)
Page<Keyword> findByKeywordIn(String keyword, Pageable pagebale);
}
The implemented method -
@Override public Page<Keyword> findByKeywordIn(String keyword, Pageable pageable){
Page<Keyword> kws = productRepository.findByKeywordIn(keyword, pageable);
return kws;
}
But when I am getting list inside my page object by calling the method is showing unknown instance - "Page 0 of 0 containing UNKNOWN instances".
Where as I can see the query in my solr log - [ac_shard1_replica2] webapp=/solr path=/suggest_keyword params={fl=keyword,user_count,recommendation,suggest,suggest_ngram,version&start=0&q=keyword:app&q.op=AND&wt=javabin&qt=/suggest_keyword&version=2&rows=3} hits=0 status=0 QTime=1
@dbjr84 you cannot return page of type keyword (I guess it is not your model type) Please return Page or Slice of Model type (which as far as your naming convention is concerned i guess it is product).