前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Solr基础操作10

Solr基础操作10

作者头像
franket
发布2022-06-29 22:37:37
1590
发布2022-06-29 22:37:37
举报
文章被收录于专栏:技术杂记

多关键字匹配(且)

+ (%2B) 前缀代表必须包含

代码语言:javascript
复制
[root@h102 solr-5.3.0]# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&fl=id&rows=3&q=%2Bone+%2Bthree"
{
  "responseHeader":{
    "status":0,
    "QTime":11,
    "params":{
      "fl":"id",
      "indent":"true",
      "q":"+one +three",
      "wt":"json",
      "rows":"3"}},
  "response":{"numFound":20,"start":0,"maxScore":0.41965395,"docs":[
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/schema/SimplePreAnalyzedParser.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/util/doc-files/min-should-match.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/handler/DumpRequestHandler.html"}]
  }}
[root@h102 solr-5.3.0]# 

By default, when you search for multiple terms and/or phrases in a single query, Solr will only require that one of them is present in order for a document to match. Documents containing more terms will be sorted higher in the results list. You can require that a term or phrase is present by prefixing it with a “+”; conversely, to disallow the presence of a term or phrase, prefix it with a “-“. To find documents that contain both terms “one” and “three”, enter +one +three in the q param in the core-specific Admin UI Query tab. Because the “+” character has a reserved purpose in URLs (encoding the space character), you must URL encode it for curl as “%2B”: To search for documents that contain the term “two” but don’t contain the term “one”, enter +two -one in the q param in the Admin UI. Again, URL encode “+” as “%2B”:

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 多关键字匹配(且)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档