Solr/SolrJ:如何突出显示非文本字段?
我成功地在基于文本的字段类型上启用了突出显示,但在非文本字段类型上没有启用突出显示 如何配置solr以突出显示非文本字段类型?我在网上找不到非文本字段的示例。有可能吗 具体来说,我想突出显示文档中满足查询的日期值Solr/SolrJ:如何突出显示非文本字段?,solr,solrj,Solr,Solrj,我成功地在基于文本的字段类型上启用了突出显示,但在非文本字段类型上没有启用突出显示 如何配置solr以突出显示非文本字段类型?我在网上找不到非文本字段的示例。有可能吗 具体来说,我想突出显示文档中满足查询的日期值 我正在使用solrJ生成查询,这可能是限制因素吗?在非“文本”字段上无法突出显示。看看这个: /** * Returns a collection of the names of all stored fields which can be * highlighted th
我正在使用solrJ生成查询,这可能是限制因素吗?在非“文本”字段上无法突出显示。看看这个:
/**
* Returns a collection of the names of all stored fields which can be
* highlighted the index reader knows about.
*/
public Collection<String> getStoredHighlightFieldNames() {
if (storedHighlightFieldNames == null) {
storedHighlightFieldNames = new LinkedList<String>();
for (String fieldName : fieldNames) {
try {
SchemaField field = schema.getField(fieldName);
直到这里
storedHighlightFieldNames.add(fieldName);
}
} catch (RuntimeException e) { // getField() throws a SolrException, but it arrives as a RuntimeException
log.warn("Field \"" + fieldName + "\" found in index, but not defined in schema.");
}
}
}
return storedHighlightFieldNames;
}
你不能像刚才解释的那样做 但让Solr来处理这个问题非常简单。为日期创建另一个字符串格式的字段。现在只需使用copyField:
<field name="date1" type="date" indexed="true" stored="true" />
<field name="date1_str" type="string" indexed="true" stored="true" />
<copyField source="date1" dest="date1_str"/>
然后只需将字段date1\u str添加到您的查询中。谢谢!尽管正如我所担心的那样:(然后如何确定哪些非文本字段导致文档满足查询?您的意思可能是哪些非文本字段与查询的一部分匹配。抱歉,没有返回直接匹配的实现。感谢您的回复,我不确定我们谈论的是同一件事……谢谢您的回复,我不确定但是,我们谈论的是同一件事……假设我有一个文档,它有两个文本字段a=“aaaaa”和B=“sssss”,一个日期字段D=20100101。请求用户初始化查询(a:blah和D:20100101)。它返回文档,但我不知道文档中的哪个字段满足查询(即日期)因为日期没有突出显示。
<field name="date1" type="date" indexed="true" stored="true" />
<field name="date1_str" type="string" indexed="true" stored="true" />
<copyField source="date1" dest="date1_str"/>