Hi, On Mon, May 23, 2011 at 8:52 PM, Kissue Kissue <kissue...@gmail.com> wrote:
> Thanks Anuj for your reply. Would it then include it as a field in my POJO? > I meant the score given by Solr in response to the search query. Is it an application specific score that you want to include? > How do i define such field? I have a POJO with the @Field annotation which > is mapped to fields in my schema. > At the time of indexing, you need not specify the score. The score is calculated based on the relevance of the query against the matched documents. If you have an application specific score or weight that you want to add, you can add it as a separate field but what I understand from your query is that you want the score that Solr gives to each search results. In that case, just setting the property IncludeScore to true while constructing the query object (as shown in the example that I gave earlier) will suffice. >From the query response, you can then query for the maximum score, as well as each document's score. For example- // get the response QueryResponse results = getSearchServer().query(query); // get the documents SolrDocumentList resultDocs = results.getResults(); // get the maximum score float maxScore = resultDocs.getMaxScore(); // iterate through the documents to see the results for(SolrDocument doc : resultDocs){ // get the score Object score = doc.get("score"); } Hope that helps. Regards, Anuj > > Thanks. > > On Mon, May 23, 2011 at 4:10 PM, Anuj Kumar <anujs...@gmail.com> wrote: > > > Hi, > > > > If you mean SolrJ (as I understand by your description of POJOs), you can > > add the score by setting the property IncludeScore to true. For example- > > > > SolrQuery query = new SolrQuery(). > > setQuery(keyword). > > *setIncludeScore(true);* > > > > Regards, > > Anuj > > > > On Mon, May 23, 2011 at 8:31 PM, Kissue Kissue <kissue...@gmail.com> > > wrote: > > > > > Hi, > > > > > > I am currently using Solr and indexing/reading my documents as POJO. > The > > > question i have is how can i include the score in the POJO for each > > > document > > > found in the index? > > > > > > Thanks. > > > > > >