Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting 如何在solrJ中使用查询语法?_Sorting_Solr_Lucene_Solrj_Dismax - Fatal编程技术网

Sorting 如何在solrJ中使用查询语法?

Sorting 如何在solrJ中使用查询语法?,sorting,solr,lucene,solrj,dismax,Sorting,Solr,Lucene,Solrj,Dismax,我需要在solrJ中实现这个查询 &sort=query($manu_sort,0) desc, query($manu_service_sort,0) desc, query($seller_sort,0) desc, _s_name asc, sku asc &manu_sort=ManufacturerName:"Service Champ" &manu_service_sort=ManufacturerName:"SERVICE CHAMP" &selle

我需要在solrJ中实现这个查询

&sort=query($manu_sort,0) desc, query($manu_service_sort,0) desc, query($seller_sort,0) desc, _s_name asc, sku asc &manu_sort=ManufacturerName:"Service Champ" &manu_service_sort=ManufacturerName:"SERVICE CHAMP" &seller_sort=BestSeller:true
当我直接添加到我的代码时

        customSort = "&sort=query($manu_sort,0) desc, query($manu_service_sort,0) desc, query($seller_sort,0) desc, _s_name asc, sku asc &manu_sort=ManufacturerName:"Service Champ" &manu_service_sort=ManufacturerName:"SERVICE CHAMP" &seller_sort=BestSeller:true"; 
        queryQ = queryQ+customSort;
        solrQuery.setQuery(queryQ);
        QueryResponse e = this.provider.get(this).query(solrQuery, METHOD.POST);
这会抛出类似于

 no field name specified in query and no default specified via 'df' param

有人能帮忙吗?

我无法得到您的查询…但可以建议一个示例代码,它可能对您有所帮助

  String solrUrl = "http://localhost:8983/solr/";
  HttpSolrClient httpSolrClient = new HttpSolrClient.Builder(solrUrl).build();
  SolrQuery query = new SolrQuery();
  query.setQuery("*:*");
  query.set("defType","edismax");
  //query.set("qf","file_name^10 content_text^1");
  query.addFilterQuery("name : abcdef");

  //sorting & direction
  query.addSort("Name_of_field_For_sorting", SolrQuery.ORDER.desc);

  // set the debug 
  //query.set("debug",  "true");

  //for faceting
  //query.setFacet(true);
  //query.addFacetField("name_of_the_Field")
  //query.setFacetLimit(10);

  //set the fields
  query.setFields(new String[] {"id", "name"});

  // for highlighting 
  query.setHighlight(true);
  query.addHighlightField("Name_of_field_to_be_Highlighted");
  query.addHighlightField("content_text");
  query.setHighlightSimplePre("<hlt>");
  query.setHighlightSimplePost("</hlt>");
  query.setHighlight(true).setHighlightSnippets(2);
  query.setHighlightFragsize(150);

  query.setStart(0);
  query.setRows(10);

  QueryResponse response = httpSolrClient.query(query);
  SolrDocumentList results = response.getResults();
  //iterate the results
  for (int i = 0; i < results.size(); ++i) {
    System.out.println(results.get(i));
  }
SolrQuery query = new SolrQuery();   
String nested = "";
nested += "Field_name:";
nested += "Field_Value";
nested += " AND _query_:\"{!dismax qf=Field_name1=";
nested += "Field_Value1";
nested += "}\"";
query.setQuery(nested);
String fieldList = "id,name,category";
query.set("fl", fieldList);
QueryResponse response = httpSolrClient.query(query);