Solr学习总结-查询

来源:互联网 发布:常熟淘宝客服招聘 编辑:程序博客网 时间:2024/05/17 03:26

指定field查询

http://localhost:8983/solr/select?q=author:rafal

按照dismax查询:可以指定多个域,每个域的匹配都有不同的分数

http://localhost:8080/solr/select?q=title&qf=title^1 text^5&defType=dismax

按照“或”的关系查询

http://localhost:8983/solr/select?q=author:(solr cookbook)

按照某个field排序

http://localhost:8983/solr/select?q=solr&sort=author+asc,score+desc

选择不同的query parser,可以定制针对不同的单词采用不同的查找方法

http://localhost:8983/solr/select?q=book&qf=title&defType=dismax

执行phrase查询以及slope

http://localhost:8983/solr/select?q=title:"2010 report"~1

针对phrase查询,如果满足单词相邻,boost他

http://localhost:8983/solr/select? defType=dismax&pf=title^100&q=2010+report&qf=title

http://localhost:8983/solr/select?q=title:(2010+AND+report)+OR+title:"2010+report"^100

针对具体的查询串(一般是string),给予排名自定义(前提是得分相同)。首先在sorlconfig.xml中定义下面

<searchComponent name="elevator" class="solr.QueryElevationComponent"><str name="queryFieldType">string</str><str name="config-file">elevate.xml</str></searchComponent><requestHandler name="/promotion" class="solr.SearchHandler"><arr name="last-components"><str>elevator</str></arr></requestHandler>
其次编写elevate.xml:
<?xml version="1.0" encoding="UTF-8" ?><elevate><query text="solr"><doc id="3" /><doc id="1" exclude="true" /><!-- 此文件不会被查询到,相当于被百度屏蔽 --></query></elevate>
最后查询:http://localhost:8983/solr/promotion?q=solr

按照距离查询

http://localhost:8983/solr/select?q=company&sort=dist(2,x,y,0,0)+asc

指定满足查询词的数量:其中mm即为妖满足的查询词的数量

http://localhost:8983/solr/select?q=book+revised+another+ different+word+that+doesnt+count&defType=dismax&mm=2

按照指定的field排名,下面是按照sold排名评分:

http://localhost:8983/solr/select?defType=dismax&qf=title&q=revised&fl=*,score&bf=product(sold)

嵌入查询,满足花括号内的条件的将分数相乘

http://localhost:8983/solr/select?q=revised+AND+book+AND+_query_:"{!dismax qf=title pf=title^10 v=$qq}"&qq=revised+book


原创粉丝点击