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

Solr基础操作9

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

属性匹配

q=field:value 可以进行更精细的属性限定

比如只搜索 _version_1511824568810995712 的文档

代码语言:javascript
复制
[root@h102 solr-5.3.0]# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=_version_:1511824568810995712"
{
  "responseHeader":{
    "status":0,
    "QTime":18,
    "params":{
      "indent":"true",
      "q":"_version_:1511824568810995712",
      "wt":"json"}},
  "response":{"numFound":1,"start":0,"maxScore":7.851185,"docs":[
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-morphlines-cell/allclasses-noframe.html",
        "title":["All Classes (Solr 5.3.0 API)"],
        "stream_content_type":["text/html"],
        "stream_size":[1059],
        "content_encoding":["UTF-8"],
        "date":["2015-08-17T00:00:00Z"],
        "x_parsed_by":["org.apache.tika.parser.DefaultParser",
          "org.apache.tika.parser.html.HtmlParser"],
        "content_type":["text/html; charset=utf-8"],
        "resourcename":["/data/solr/solr-5.3.0/docs/solr-morphlines-cell/allclasses-noframe.html"],
        "dc_title":["All Classes (Solr 5.3.0 API)"],
        "_version_":1511824568810995712}]
  }}
[root@h102 solr-5.3.0]# 

多关键字匹配(或)

如果要进行多关键字搜索,就使用 + ,例如: q=ui+testq=’ui+test’

代码语言:javascript
复制
[root@h102 solr-5.3.0]# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&fl=id&rows=3&q=test"
{
  "responseHeader":{
    "status":0,
    "QTime":13,
    "params":{
      "fl":"id",
      "indent":"true",
      "q":"test",
      "wt":"json",
      "rows":"3"}},
  "response":{"numFound":204,"start":0,"maxScore":0.48749265,"docs":[
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-test-framework/overview-summary.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-test-framework/org/apache/solr/analysis/package-frame.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-test-framework/org/apache/solr/core/package-frame.html"}]
  }}
[root@h102 solr-5.3.0]# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&fl=id&rows=3&q=ui"
{
  "responseHeader":{
    "status":0,
    "QTime":8,
    "params":{
      "fl":"id",
      "indent":"true",
      "q":"ui",
      "wt":"json",
      "rows":"3"}},
  "response":{"numFound":31,"start":0,"maxScore":0.3156422,"docs":[
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/servlet/package-summary.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/handler/admin/package-summary.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/core/package-use.html"}]
  }}
[root@h102 solr-5.3.0]# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&fl=id&rows=3&q=ui+test"
{
  "responseHeader":{
    "status":0,
    "QTime":13,
    "params":{
      "fl":"id",
      "indent":"true",
      "q":"ui test",
      "wt":"json",
      "rows":"3"}},
  "response":{"numFound":234,"start":0,"maxScore":0.17063226,"docs":[
      {
        "id":"/data/solr/solr-5.3.0/docs/changes/Changes.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-test-framework/overview-summary.html"},
      {
        "id":"/data/solr/solr-5.3.0/docs/solr-test-framework/org/apache/solr/analysis/package-frame.html"}]
  }}
[root@h102 solr-5.3.0]# 

Tip: 同时匹配多个关键字的结果会排到更前列

本文系转载,前往查看

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

本文系转载前往查看

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

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