我的目标是检索Solr索引中的JSON类型字段,并对这些字段执行搜索查询 .
我在Solr索引中有以下文档,并在Solr中使用自动生成的模式使用无模式功能 .
发表http://localhost:8983/solr/test1/update?commitWithin=1000
[
{"id" : "1", "type_s":"book", "title_t" : "The Way of Kings", "author_s" : "Brandon Sanderson",
"miscinfo": {"provider": "orielly", "site": "US"}
},
{"id" : "2", "type_s":"book", "title_t" : "The Game of Thrones", "author_s" : "James Sanderson",
"miscinfo": {"provider": "pacman", "site": "US"}
}
]
我看到JSON类型在schemaField类型中存储为字符串,如下面的输出中所示
GET http://localhost:8983/solr/test1/schema/fields
{
"name":"miscinfo",
"type":"strings"}
我曾尝试使用post中提到的srcField . 但是,检索json类型的查询将返回空响应 . 以下是用于相同的GET请求
GET http://localhost:8983/solr/test1/select?q=1&fl=miscinfo&wt=json
GET http://localhost:8983/solr/test1/select?q=1&fl=miscinfo,source_s:[json]&wt=json
此外,对JSON类型字段内的值的搜索查询返回空响应
http://localhost:8983/solr/test1/select?q=pacman&wt=json
{
"responseHeader": {
"status": 0,
"QTime": 0,
"params": {
"q": "pacman",
"json": "",
"wt": "json"
}
},
"response": {
"numFound": 0,
"start": 0,
"docs": []
}
}
请帮助在Solr中搜索对象类型 .
1 回答
你检查过这个:https://cwiki.apache.org/confluence/display/solr/Response+Writers