searchsolrlucenesolrconfig

SOLR search not including data within JSON Field


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"
    },
  ],
}

Solution

  • qf=title^300 tells Solr which fields it should search and the weight given to each field.

    qf=title^300 json would search both the title field and the json field, and give a hit in title a 300x increase in score compared to a hit it json.