Dear all, I'm trying to get tv.tf_idf values from my Solr documents into the termvector. I am using SolrJ.
However it is not working. I'm setting the values to true (tv.tf_idf) in my search: public static QueryResponse doQuery(SolrServer server, String queryEnt, String myCollection) throws SolrServerException { SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(queryEnt); solrQuery.set("collectionName", myCollection); solrQuery.addHighlightField("texto") .addHighlightField("titular") .setHighlightSnippets(200000) .setHighlightFragsize(0); solrQuery.set("hl.useFastVectorHighlighter", true); solrQuery.set("hl.fragListBuilder", "single"); solrQuery.set("tv.fl", "titular"); solrQuery.set("tv.tf", true); solrQuery.set("tv.tf_idf", true); solrQuery.set("hl.fragmentsBuilder", "colored"); solrQuery.setHighlightSimplePre("<span class=\"item\">"); solrQuery.setHighlightSimplePost("</span>"); solrQuery.set("fl", "c_noticia titular texto"); solrQuery.setStart(start); solrQuery.setRows(nbDocuments); return server.query(solrQuery); } and then I am using the code in: http://stackoverflow.com/questions/8977852/how-to-parse-the-termvectorcomponent-response-to-which-java-object, to get the values: public static void printOr(QueryResponse response) throws SolrServerException, ParseException, IOException { Iterator<Entry<String, Object>> termVectors = ((NamedList) response.getResponse().get("termVectors")).iterator(); while(termVectors.hasNext()){ Entry<String, Object> docTermVector = termVectors.next(); for(Iterator<Entry<String, Object>> fi = ((NamedList)docTermVector.getValue()).iterator(); fi.hasNext(); ){ Entry<String, Object> fieldEntry = fi.next(); if(fieldEntry.getKey().equals("contents")){ for(Iterator<Entry<String, Object>> tvInfoIt = ((NamedList)fieldEntry.getValue()).iterator(); tvInfoIt.hasNext(); ){ Entry<String, Object> tvInfo = tvInfoIt.next(); NamedList tv = (NamedList) tvInfo.getValue(); System.out.println("Vector Info: " + tvInfo.getKey() + " tf: " + tv.get("tf") + " df: " + tv.get("df") + " tf-idf: " + tv.get("tf-idf")); } } } } } But i'm having this error: Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.solr.common.util.NamedList Could anybody helpme please with this problem? thanks a lot in advance. Silvia