Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search SOLR搜索不包括JSON字段中的数据_Search_Solr_Lucene_Solrconfig - Fatal编程技术网

Search SOLR搜索不包括JSON字段中的数据

Search SOLR搜索不包括JSON字段中的数据,search,solr,lucene,solrconfig,Search,Solr,Lucene,Solrconfig,我的SOLR索引中包含了一堆文档。这些文档包含一个包含JSON数据的字段 当我使用关键字执行查询时,我希望也搜索JSON字段。现在它不起作用了 查询: { "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"keyword_to_search", "defType":"edismax", "qf":"title^300", "fl":"field_name:

我的SOLR索引中包含了一堆文档。这些文档包含一个包含JSON数据的字段

当我使用关键字执行查询时,我希望也搜索JSON字段。现在它不起作用了

查询:

{
  "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":[]
  }
}
{
  ...
  "field_name": "field_value",
  "columns": [
    ...
    {
        "nested_key": "nested_value_1"
    },
    {
        "nested_key": "nested_value_1"
    },
  ],
}
实际文档包含一个JSON字段,数据为“关键字搜索”

"field_name":"{\"field_key\": \"keyword_to_search\"}",
该字段似乎可以搜索,因为我可以在查询时返回文档:

{
  "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\"}",
    }
  ]}
}
如何修改我的查询以包含此内容

JSON结构:

{
  "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":[]
  }
}
{
  ...
  "field_name": "field_value",
  "columns": [
    ...
    {
        "nested_key": "nested_value_1"
    },
    {
        "nested_key": "nested_value_1"
    },
  ],
}

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


qf=title^300 json
将搜索
title
字段和
json
字段,并在
title
中命中,与命中相比,得分增加300倍
json

谢谢,由于json字段的大小,这使得查询非常缓慢。我应该将其作为单独的文档索引吗?如果是这样的话,我该如何将它们与父级关联,因为这是我想要返回的,而不是新的json文档。如果您想要搜索json中的某个特定字段,请将其作为单独的字段索引。我们在这里谈论多少内容?将其提取为单独的文档不会减少要搜索的标记数量,因此它也取决于
field\u name
的定义。它是一个大型JSON对象,超过20k个字符。我在原始文章中添加了JSON字段的结构。我需要搜索数组对象中包含的3/4项。我接受这个答案,因为它确实有效。非常感谢。