1

I have a bunch of documents included in my SOLR index. These documents contain a field that contains JSON data.

When I perform a query with a keyword I want that JSON field to be also searched. Right now it is not working.

QUERY:

{
  "responseHeader":{
    "status":0,
    "QTime":0,
    "params":{
      "q":"keyword_to_search",
      "defType":"edismax",
      "qf":"title^300",
      "fl":"field_name:[json]",
      "wt":"json",
      "_":"1551735180672"
    }
  },
  "response":{
    "numFound":0,
    "start":0,
    "docs":[]
  }
}

There is actual documents that contains a JSON field with the data 'keyword_to_search'.

"field_name":"{\"field_key\": \"keyword_to_search\"}",

The field seems to be searchable as I can return the document when querying:

{
  "responseHeader":{
    "status":0,
    "QTime":0,
    "params":{
      "q":"{!term f=field_name}keyword_to_search",
      "_":"1551735532524"
    }
  },
  "response":{"numFound":1,"start":0,"docs":[
    {
    ...
    "field_name":"{\"field_key\": \"keyword_to_search\"}",
    }
  ]}
}

How can modify my query to include this?

JSON Structure:

{
  ...
  "field_name": "field_value",
  "columns": [
    ...
    {
        "nested_key": "nested_value_1"
    },
    {
        "nested_key": "nested_value_1"
    },
  ],
}
4

1 回答 1

2

qf=title^300告诉 Solr 它应该搜索哪些字段以及赋予每个字段的权重。

qf=title^300 json将同时搜索titlefield 和jsonfield,并且title与 hit it 相比,hit 的得分增加了 300 倍json

于 2019-03-05T07:36:21.953 回答