Solr基础操作9

2022-06-29 22:37:18 浏览数 (1)

属性匹配

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: 同时匹配多个关键字的结果会排到更前列

0 人点赞