I am migrating a web site from an old version of solr (1.4.1) to the current release version (5.2.1) on a different machine and noticing some differences.
In the old version, I could get highlighting with a url like this:
In the new version, one thing that's different is I need to specify a collection. Another difference is that the new version gives an error if I put text:
in front of the value of q
.
So, taking into account those differences, I end up with a URL like this:
That second URL does not give me highlighting fragments/snippets. That is to say, where the old URL would give something like this:
"highlighting":{
"document0_id":{"text":["The <em>software</em> is awesome"]}}
The new URL gives something like this:
"highlighting":{
"document0_id":{}}
What do I need to do to get highlighting fragments returned in solr 5.2.1?
[edited]
In addition, I tried selecting a single document by its id on both machines. On the old machine, a url like
http://localhost:8983/solr/select?wt=json&indent=true&q=id:thedocumentid
returns some JSON that includes a text
field containing the full searchable text of the original HTML document. On the new machine a similar url (but one that includes the collection):
http://localhost:8983/solr/default/select?wt=json&indent=true&q=id:thedocumentid
...returns similar JSON that does not include the text
field.
I note that searching returns the correct results; the problem is that on the new machine, the results do not include the highlighting fragments. So it seems like maybe the issue is that I need to specify that these documents have a text field when I index them; how do I do that?
答案 0 :(得分:1)
一位同事(未受赏金诱惑)注意到我的text
字段在我的schema.xml中有stored="false"
,并建议将其更改为true
。这就行了。
答案 1 :(得分:0)
在第一个查询中,您将专门在文本字段中搜索,而在第二个查询中则不是。
在第二部分你提到了hl.fl,这意味着&#34;指定要突出显示的字段列表。接受以逗号或空格分隔的字段列表,Solr应为其生成突出显示的片段。如果留空,则突出显示defaultSearchField&#34;
通过进行更改再试一次......