> I tried below two methods(edismax & OR) in solrj java coding but I did not > get the results in order, like listing matching records at the top. Am I > doing anything wrong in below java coding? > > > Method 1 > : > SolrQuery query = new SolrQuery().setStart(first).setRows( > searchCommand.getRowsPerPage()); > //setting query > query.setQuery("*"); > > //setting spatial params for getting results by distance > query.setParam("spatial", "true"); > query.setParam("pt","17.4020637,78.4840052"); > query.setParam("sfield", "geo_lat_long"); > query.addSort("geodist()", ORDER.asc); > > //setting params for edismax, order by code at top > query.setParam("*defType*","*edismax*"); > query.setParam("*bq*", "*code:*888;**"); > > //setting filter query > query.setFilterQueries("table_for:[2 TO *]"); > > //getting results from solr > QueryResponse rsp = server.query( query )
Are all those asterisk characters (*) really part of that code? If any of them are for emphasis, please send your code again, but do it clean, and don't use HTML or rich text email. A query of * is not valid syntax. For all docs with edismax, set a blank query string and set the q.alt parameter to the *:* special string for all docs. It's best to set q.alt in the handler definition, but you can do it as a param with SolrJ too. > Method 2 > : > > Other method tried for order by code > //setting params for edismax, order by code at top > > > SolrQuery query = new SolrQuery().setStart(first).setRows( > searchCommand.getRowsPerPage()); > > //setting query with or condition > query.setQuery("**:* or code:*888**") > > //setting spatial params for getting results by distance > query.setParam("spatial", "true"); > query.setParam("pt","17.4020637,78.4840052"); > query.setParam("sfield", "geo_lat_long"); > query.addSort("geodist()", ORDER.asc); > > //setting filter query > query.setFilterQueries("table_for:[2 TO *]"); > > //getting results from solr > QueryResponse rsp = server.query( query ) This time you've got the *:* in there, but with extra asterisks that may or may not actually be there in the code, as mentioned previously. I'm reading this on a text mail client, so if you've used fonts, colors, or attributes like bold/italic, I can't see them. Also, unless the edismax parameter for lowercase operators is true, "or" must be "OR" for it to work. That parameter may default to true, I'm not sure. The OR clause is unnecessary. Asking for "all documents OR a subset of documents" will always return all documents. If you want to affect the order of documents, you need to use boosting. Perhaps a bq param set to "code:888^100" would work? You might need to adjust the 100 value up or down. Thanks, Shawn