Hey Community. I write my first component and now i got a problem hear is my code:
@Override public void prepare(ResponseBuilder rb) throws IOException { try { rb.req.getParams().getBool("topoffers.show", true); String client = rb.req.getParams().get("client", "1"); BooleanQuery[] queries = new BooleanQuery[2]; queries[0] = (BooleanQuery) DisMaxQParser.getParser( rb.req.getParams().get("q"), DisMaxQParserPlugin.NAME, rb.req) .getQuery(); queries[1] = new BooleanQuery(); Occur occur = BooleanClause.Occur.MUST; queries[1].add(QueryParsing.parseQuery("ups_topoffer_" + client + ":true", rb.req.getSearcher().getSchema()), occur); Query q = Query.mergeBooleanQueries(queries[0], queries[1]); DocList ergebnis = rb.req.getSearcher().getDocList(q, null, null, 0, 5, 0); String[] machineIds = new String[5]; int position = 0; DocIterator iter = ergebnis.iterator(); while (iter.hasNext()) { int docID = iter.nextDoc(); Document doc = rb.req.getSearcher().getReader().document(docID); for (String value : doc.getValues("machine_id")) { machineIds[position++] = value; } } Sort sort = rb.getSortSpec().getSort(); if (sort == null) { rb.getSortSpec().setSort(new Sort()); sort = rb.getSortSpec().getSort(); } SortField[] newSortings = new SortField[sort.getSort().length + 5]; int count = 0; for (String machineId : machineIds) { SortField sortMachineId = new SortField("map(machine_id," + machineId + "," + machineId + ",1,0) desc", SortField.DOUBLE); newSortings[count++] = sortMachineId; } SortField[] sortings = sort.getSort(); for (SortField sorting : sortings) { newSortings[count++] = sorting; } sort.setSort(newSortings); rb.getSortSpec().setSort(sort); } catch (ParseException e) { LoggerFactory.getLogger(Topoffers.class).error( "Fehler bei den Topoffers!", this); LoggerFactory.getLogger(Topoffers.class).error(e.toString(), this); } } Why can't i manipulate the sort? Is there something i miss understand? This search component is added as a "first-component" in the solrconfig.xml. Please can anyone help me?? -- View this message in context: http://lucene.472066.n3.nabble.com/Sort-five-random-Top-Offers-to-the-top-tp3355469p3376166.html Sent from the Solr - User mailing list archive at Nabble.com.