solr查询语法

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

结果如下:

  <?xml version="1.0" encoding="UTF-8"?>
- < response >
- < lst name =" responseHeader ">
  < int name =" status "> 0 </ int >
  < int name =" QTime "> 73 </ int >
- < lst name =" params ">
  < str name =" fl "> url,title,content </ str >
  < str name =" indent "> on </ str >
  < str name =" start "> 0 </ str >
  < str name =" q "> 计算机 </ str >
  < str name =" version "> 2.2 </ str >
  < str name =" rows "> 10 </ str >
  </ lst >
  </ lst >
- < result name =" response " numFound =" 26 " start =" 0 ">
- < doc >
  < str name =" content "> 中国畜牧业信息网人才招聘-简历搜索 中国畜牧业信息网 人才招聘系统 加入收藏 协会网站 中国畜牧业信息网    本站首页 | 人才搜索 | 职位搜索 | 个人服务 | 企业服务 | 职场指导 | 协会招聘 | 使用说明 使用步骤:(1) 注册为中国畜牧业信息网单位会员 (2) 申请开通人才招聘服务 (3) 登陆人才招聘系统,发布职位信息 (4) 搜索简历 (5) 收藏简历或发送面试邀请。 用户: 未登陆 修改基本信息 发布职位信息 职位信息 简历搜索 简历收藏夹 邀请面试记录 回 收 站 退    出 简历搜索 学历:   不限 初中 高中 中专 大专 本科 硕士 博士 性别: 不限 男 女 工作经验:   不限 无 在校大学生 应届毕业生 一年以下 一年到三年 三年到五年 五年到十年 十年以上 工作性质: 不限 全职 兼职 实习 职位:   不限 行政管理・文职 市场营销 计算机・网络 技术人员 科研・教育 地址:   不限 北京 上海 天津 重庆 山东 福建 云南 江西 广东 安徽 湖南 湖北 江苏 浙江 四川 贵州 甘肃 青海 山西 陕西 河南 黑龙江 河北 辽宁 吉林 内蒙古 广西 新疆 宁夏 海南 台湾 澳门 香港 不限 薪水: 不限 1000以下 1000-3000 3000-5000 5000以上 不限 面议 更新时间:   不限 一天内 三天内 一周以内 一个月内 ----------------------------------------------------------------------------------------- 建议使用1024*768分辨率浏览本网站 Copyright@2003 CAAA All rights reserved. 中国畜牧业协会 版权所有 北京市朝阳区曙光西里甲6号时间国际大厦A座9层 邮编 100028 电话: 010-58677700 传真:010-58677809 电子邮件: xx@caaa.cn 设计、程序:中国畜牧业协会信息中心  备案序号: 京ICP备05023006号   </ str >
  < str name =" title "> 中国畜牧业信息网人才招聘-简历搜索 </ str >
  < str name =" url "> http://www.caaa.cn/zhaopin/company/search_resume.php </ str >
  </ doc >
  只出现这三个字段。
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.通配符* 这个太熟悉了 随便来
结合各种语法的混合定位搜索,让结果更精确。
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值