As we all know, #1154116: Search API Solr retrieving search results data directly from SOLR, avoid going through MySQL added a way to directly retrieve the result data from Solr, without loading the entities. #1177648: Enable Solr's built-in highlighting on the other hand added an option to generate highlighted excerpts.

Now, a combined feature would be to retrieve the fields directly from Solr, but already highlighted. This would, e.g., allow to not only present an excerpt, but also highlight the search terms in displayed titles, or other data.
Patch coming soon …

Comments

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new6.52 KB

The attached patch should do this.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

118218’s picture

The highlight feature does not work for me.

I did dozens of tests, but the only excerpt I was able to generate was: "Test ... Test ...".

The real content of this node is "Test Testé ok salut Proin semper bibendum triplet. Nulla facilisi."

Apart from this, I'm not able to get any other excerpt. Why?

It's very strange because this feature works very well with "Apache Solr Search Integration". But this module is not as flexible as yours, with views...

Please I need this wonderful feature!

jtse’s picture

Bump. Experiencing same issue as #4.

UPDATE #1:
The excerpt appears fine if the matched terms are in the title. If the terms are in the body, however, all I see is "[TERM]...[TERM]..." as with #4

UPDATE #2:
It looks like it does not return the proper highlighted excerpt for text fields with summary. It works fine for text fields without summary. Investigating cause...

UPDATE #3:
Ignore UPDATE #2. The issue specific to the body field. If I create another field like the body (e.g., field_body2), the excerpt behaves as expected.

presleyd’s picture

I see the same issue as 5. Other text fields seem to return a usable excerpt but the default 'body' field just returns "[TERM]...[TERM]..."

Update... well after adding another field now even the body excerpts show up fine. That's a weird one.

that0n3guy’s picture

Status: Closed (fixed) » Needs work
StatusFileSize
new24.61 KB
new38.55 KB

I'm going to mark this as "needs work" if thats ok. I am running solr 3.5 and getting similar results to the above individuals (with the test... test.. thing).

Here are some images to show what we are talking about. I get the same result whether I'm using views excerpt field or just search api pages module (which is shown in the images).

This is with "Return an excerpt for all results" unchecked:
No Excerpt setting

This is with "Return an excerpt for all results" checked
Excerpt Setting

Whether I have "Retrieve result data from Solr" or "Highlight retrieved data" checked doesn't seem to matter.

Also, it doesn't say "text" every time. It says whatever I search. So if I search "simple". I get "simple...".

jtbayly’s picture

Status: Needs work » Needs review

I had this problem too, but I was able to fix it by disabling the tokenizer processor in the workflow tab of the Search API index settings.

See this issue: http://drupal.org/node/1588612

drunken monkey’s picture

Yes, please deactivate all processors (or at least the default ones) when using a Solr server!

Please report back if you're still experiencing difficulties.

gmclelland’s picture

My search excerpts highlighting is working, but is it normal that they show html tags in the search excerpts? Can those be stripped out somehow?

Anonymous’s picture

A lot of people will tell you to disable all Processors in the Workflow settings. However, if you wish to do nothing with the HTML tags, you can enable the HTML filter.

colan’s picture

Status: Needs review » Fixed

No more unsolved problems after #9. See #1064520: Add a processor for highlighting for Views integration.

Marking #1581638: Highlighting searched keyword as a duplicate.

drunken monkey’s picture

Title: Add option to directly highlight retrieved data from Solr » Document that enabling HTML filter makes sense
Category: feature » task
Status: Fixed » Needs review
StatusFileSize
new785 bytes

A lot of people will tell you to disable all Processors in the Workflow settings. However, if you wish to do nothing with the HTML tags, you can enable the HTML filter.

Now that you mention it, I can see how this might actually be very useful. And for years I've preached the opposite, without really thinking about it … Oops.
Thanks for opening my eyes in this respect. Attached is a patch which would clarify this in the README.txt file. Anywhere else it should be changed? (The service class description is already verbose enough, I think, and also doesn't state this as absolutely as the README.txt.)

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.