schema.xml中字段及defaultSearchField设置
<fields>
<field name="id" type="string" stored="true" indexed="true"/>
<field name="title" type="string" indexed="true" stored="true" />
<!-- core fields -->
<field name="segment" type="string" stored="true" indexed="false"/>
<field name="digest" type="string" stored="true" indexed="false"/>
<field name="boost" type="float" stored="true" indexed="false"/>
<!-- fields for index-basic plugin -->
<field name="host" type="string" stored="false" indexed="true"/>
<field name="url" type="url" stored="true" indexed="true"
required="true"/>
<field name="content" type="text_zh" stored="true" indexed="true"/>
<field name="cache" type="string" stored="true" indexed="false"/>
<field name="tstamp" type="date" stored="true" indexed="false"/>
<!-- fields for index-anchor plugin -->
<field name="anchor" type="string" stored="true" indexed="true"
multiValued="true"/>
<!-- fields for index-more plugin -->
<field name="type" type="string" stored="true" indexed="true"
multiValued="true"/>
<field name="contentLength" type="long" stored="true"
indexed="false"/>
<field name="lastModified" type="date" stored="true"
indexed="false"/>
<field name="date" type="date" stored="true" indexed="true"/>
<!-- fields for languageidentifier plugin -->
<field name="lang" type="string" stored="true" indexed="true"/>
<!-- fields for subcollection plugin -->
<field name="subcollection" type="string" stored="true"
indexed="true" multiValued="true"/>
<!-- fields for feed plugin (tag is also used by microformats-reltag)-->
<field name="author" type="string" stored="true" indexed="true"/>
<field name="tag" type="string" stored="true" indexed="true" multiValued="true"/>
<field name="feed" type="string" stored="true" indexed="true"/>
<field name="publishedDate" type="date" stored="true"
indexed="true"/>
<field name="updatedDate" type="date" stored="true"
indexed="true"/>
<!-- fields for creativecommons plugin -->
<field name="cc" type="string" stored="true" indexed="true"
multiValued="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>content</defaultSearchField>
1.预设搜索字段是content所以只需要直接输入关键词就可以在content中进行搜索。
如欲查询特定字段(非预设字段),请在查询词前加上该字段名称再加上 :
例如: title: java
2.q代表query input
3. version代表solr版本(建议不要变动此变量)
4. start代表显示结果从哪一笔结果资料开始,预设为0代表第一笔, rows是说要显示几笔数据,预设为10笔
5. indent代表输出的xml要不要缩行.预设为开启 on
6. 另外,要限定输出结果的内容可用 “fl=” 加上你要的字段名称,如以下这个范例:
http://localhost:8983/solr/select/?q=%E8%AE%A1%E7%AE%97%E6%9C%BA&version=2.2&start=0&rows=10&indent=on&fl=url,title,content
结果如下:
7.使用OR或者使用默认的空格则可以进行词之间的或运算,也就是结果的并集
8.使用AND或者+则是交集。
9.要排除某一个词用- eg:-java
10.使用()进行包含,比如搜索h7n9会有很多结果但是关键词不都是h7n9而只是h 7 n 9 中一个字符,这是想要的是h7n9的组就使用(h7n9)
11.增加权重^ 有时搜索若干关键词如 java j2ee 这时会有很多结果,想要把j2ee排在前面就会给j2ee加上权重变成 java j2ee^2
12.通配符* 这个太熟悉了 随便来
结合各种语法的混合定位搜索,让结果更精确。