0
我是Solr和SolrJ的新手。我正在尝试使用桌面应用程序,并且有文件(文本文件)进行索引和搜索。我想使用高亮功能并以高亮显示片段,但是当您突出显示文本时,我不会让它们显示在黄色背景中,请让我知道如何在黄色背景中显示文本。如何使用Solrj显示突出显示的文本
这里是我的代码片段:
public void TestHighLight(SolrQuery query) throws
SolrServerException, IOException {
query.setQuery("*");
query.set("hl", "true");
query.set("hl.snippets", "5");
query.set("q", "text:Pune");
query.set("hl.fl", "*");
QueryResponse queryResponse = client.query(query);
SolrDocumentList docs = queryResponse.getResults();
Iterator iter = docs.iterator();
for (int i = 0; i < docs.size(); i++) {
iter = docs.get(i).getFieldNames().iterator();
String fldVal = (String) docs.get(i).getFieldValue("id");
String docID = (String) docs.get(i).get("id");
while (iter.hasNext()) {
String highlighText = getHighlightedText(queryResponse,
"text", docID);
System.out.println(" tHighlightedText is " + highlighText);
}
}
}
输出看起来是这样的:我怎么色呢? [适用于Java开发人员Pune
非常感谢!