我的Solr Server工作正常,包括我的主查询解析器中的有效拼写检查组件。现在,我正在构建一组JSON Unmarshalling类(在Java中),将查询响应转换为数据,然后我们的webapp的其他元素将被解释。
问题是,查询标记作为JSON属性返回。因此这些是动态的并且无法在代码中预先确定。由于同一级别的其他两个结果不能被解析为类似对象,因为一个是正确拼写的布尔确定,另一个是整理产生的顶级拼写建议,这很复杂。
虽然我可以忽略它们,因为整理器的顶层元素通常会提供有效的拼写建议,但能够解组这些元素会很好,因为它们包含每个特定术语的拼写建议。
是否有某种方法可以传递查询标记(例如,在查询时传入args,将被解释为JSON属性)从Solr传递给JSON unmarshaller,作为我可以构建的一种java对象的属性名称解析这些建议?
如果没有,我不需要它们。但是构造一个无法解析为POJO的JSON似乎有点荒谬。
这是我的查询"artificail intelligrnce"
的拼写检查JSON输出的示例:
"spellcheck": {
"suggestions": [
"artificail", {
"numFound": 3,
"startOffset": 1,
"endOffset": 11,
"origFreq": 0,
"suggestion": [
{
"word": "artificial",
"freq": 1
},
{
"word": "a r t if i c a i l",
"freq": 57
},
{
"word": "certificate",
"freq": 1
}
]
},
"intelligrnce", {
"numFound": 3,
"startOffset": 12,
"endOffset": 24,
"origFreq": 0,
"suggestion": [
{
"word": "intelligence",
"freq": 3
},
{
"word": "in tell i g r nc e",
"freq": 101
},
{
"word": "inheritance",
"freq": 1
}
]
},
"correctlySpelled", false,
"collation", [
"collationQuery", "\"artificial intelligence\"",
"hits", 1,
"misspellingsAndCorrections", [
"artificail", "artificial",
"intelligrnce", "intelligence"]]]
},
谢谢!