search - 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"
},
],
}
解决方案
qf=title^300
告诉 Solr 它应该搜索哪些字段以及赋予每个字段的权重。
qf=title^300 json
将同时搜索title
field 和json
field,并且title
与 hit it 相比,hit 的得分增加了 300 倍json
。
推荐阅读
- go - 编译协议缓冲区:缺少输出指令
- gulp - 什么是 gulp 中的 rev-manifest.json 文件?
- botframework - 如何在 Microsoft Teams for Microsoft Bot Framework 中检测用户的语言?
- angular - 以角度 7 显示来自 postgresql 服务器的图像
- xml - Ant 项目没有“默认”属性,有可能吗?
- html - Css从div中隐藏红线(是一个跨度)?
- excel - 为什么带有 cell.value 的宏停止工作并返回错误 2015?
- sql - 如何在Angular 2的数据库中存储用户信息?
- azure - 在 Azure 批处理池中使用支持 GPU 容器的 VM 时,节点进入不可用状态
- sql - 即使存在 NULL 值,SQL Count NULL 值也为 0