Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to override responseWriter value #4

Open
dbjr84 opened this issue Jan 12, 2015 · 3 comments
Open

How to override responseWriter value #4

dbjr84 opened this issue Jan 12, 2015 · 3 comments
Labels

Comments

@dbjr84
Copy link

dbjr84 commented Jan 12, 2015

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.

@christophstrobl
Copy link
Owner

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.

@dbjr84
Copy link
Author

dbjr84 commented Jan 13, 2015

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 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

@rajjaiswalsaumya
Copy link

@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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants