标签:solr
前面我们在讲SolrRequestHandler和QueryResponseWriter的时候提到过两个参数‘qt‘和‘wt",这两个参数是分别用于选择对应的SolrRequestHandler和QueryResponseWriter的。solr定义了很多类似的参数,它们都分别属于某个大类中,例如"qt"和"wt"就属于CoreQueryParameters。下面罗列一下solr的所有参数列表,来源于solr官网。下面笔者会一一给大家讲解这些参数的作用。
| 
 
  | 
 
  | 
| 
 parameter  | 
 docs  | 
| 
 debugQuery  | 
|
| 
 defType  | 
|
| 
 echoHandler  | 
|
| 
 echoParams  | 
|
| 
 explainOther  | 
|
| 
 facet.*  | 
|
| 
 fl  | 
|
| 
 fq  | 
|
| 
 hl.*  | 
|
| 
 mlt.*  | 
|
| 
 omitHeader  | 
|
| 
 qt  | 
|
| 
 rows  | 
|
| 
 sort  | 
|
| 
 start  | 
|
| 
 timeAllowed  | 
|
| 
 wt  | 
q这个参数所传递的就是我们所查询的内容,例如我们要查询"feature"这个关键字,发起的请求就是
http://localhost:8080/solr/collection1/select?q=feature&wt=json&indent=truesolr针对q这个参数支持以solr query syntax的方式,就是solr特有的一种查询表达式,具体可参考文档,Solr query syntax
| 
 Examples  | 
|
| 
 sort  | 
 Meaning  | 
| 
 
  | 
 by default, it is the same as score desc(默认是按分值以降序排列)  | 
| 
 score desc  | 
 sort from highest score to lowest score(按分值以降序排列)  | 
| 
 price asc  | 
 sort in ascending order of the "price" field(按价格字段以降序排列)  | 
| 
 inStock desc, price asc  | 
 sort by "inStock" descending, then "price" ascending(按inStock字段以降序,price以升序排列)  | 
| 
 sum(x_f, y_f) desc  | 
 sort by the sum of x_f and y_f in a descending order(按x_f和y_f字段相加后降序排列)  | 
注意,并不是所有的field都能排序的。如果schema.xml里面org_name被定义成text型,请问还能sort=org_name desc吗?不能,因为text类型定义的filter已经将org_name进行了切分,一个被切分后的field也就丧失了排序资格。
<!-- numeric field types that store and index the text
         value verbatim (and hence don‘t support range queries, since the
         lexicographic ordering isn‘t equal to the numeric ordering)
-->
    <fieldType name="integer" class="solr.IntField" omitNorms="true"/>
    <fieldType name="long" class="solr.LongField" omitNorms="true"/>
    <fieldType name="float" class="solr.FloatField" omitNorms="true"/>
    <fieldType name="double" class="solr.DoubleField" omitNorms="true"/>
    <!-- Numeric field types that manipulate the value into
         a string value that isn‘t human-readable in its internal form,
         but with a lexicographic ordering the same as the numeric ordering,
         so that range queries work correctly.
-->
    <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/>| 
 Examples  | 
|
| 
 Field List  | 
 Meaning  | 
| 
 id name price  | 
 Only return the "id", "name", and "price" fields(只返回id,name,price三个字段)  | 
| 
 id,name,price  | 
 Same as above(和上面一样)  | 
| 
 id name, price  | 
 Same as above(和上面一样)  | 
| 
 id score  | 
 Return the "id" field and the score(返回id和分值)  | 
| 
 *  | 
 Return all fields the each document has(返回所有字段)  | 
| 
 * score  | 
 Return all fields each document has, along with the score(返回所有字段和分值)  | 
6.跟我学solr---请求参数详解,布布扣,bubuko.com
标签:solr
原文地址:http://blog.csdn.net/jaynol/article/details/25098667