Hello,
Thank you for putting all the patch together and maintaining the module.
I have some issues to display Highlight.
Sarnia require a numeric id for the entity, I am using solr _version_ field.
My Solr Index got a field id "file path" and the pattern is not known by drupal, the index is generated by another application.
Looking at the method below in search_api_solr/includes/service.inc
protected function extractResults(SearchApiQueryInterface $query, $response) {
$index_id = $this->getIndexId($index->machine_name);
$solr_id = $this->createId($index_id, $result['id']);
$excerpt = $this->getExcerpt($response, $solr_id, $result['fields'], $fields);
}
I can see that we are assuming the solr id field follow the pattern of an index created by drupal.
The excerpt is in the response but can't be extracted by sarnia due to the logic in search_api_solr.
What will be the best option to fix this issue? Any idea?
I am looking at overriding the methods below in sarnia/service.inc
protected function extractResults(SearchApiQueryInterface $query, $response) {
}
protected function getExcerpt($response, $id, array &$fields, array $field_mapping) {
}
Is it the best way to do it? Any suggestion or advice is welcome.
I have attached the patch that works for me.
Thank you
Comment | File | Size | Author |
---|---|---|---|
#9 | 2507513-9-search-excerpt-not-displayed.patch | 5.28 KB | mparker17 |
Comments
Comment #1
ibakayoko CreditAttribution: ibakayoko as a volunteer commentedby overriding extractResults i was able to get the snippet as long as you have a field named content.
Comment #2
ibakayoko CreditAttribution: ibakayoko as a volunteer commentedComment #3
ibakayoko CreditAttribution: ibakayoko as a volunteer commentedComment #4
jmdeleon CreditAttribution: jmdeleon commentedHi... I'm trying out this patch and I get the following messages:
It appears at that line 503, you make an assumption that the set of fields will include a unique-value 'id' field. In one of the use cases I have, the unique field is not named 'id'. You might want to test for its existence and handle accordingly.
Comment #5
ZeiP CreditAttribution: ZeiP at Avoltus Oy for City of Turku commentedWorked well with an index containing the id field. Thanks!
Comment #6
ibakayoko CreditAttribution: ibakayoko as a volunteer commentedComment #7
seanBThe patch works for me! Coding standards are not being followed, so that could be improved...
Comment #8
jmdeleon CreditAttribution: jmdeleon commentedIf the original submitter of the patch -- or anyone else -- would like to clean it up:
I would welcome integrating this patch.
I don't have use-cases in the current work I do with Sarnia where an excerpt needs to be returned, so any patch ought to be tested by others, as well as the original use-case.
Comment #9
mparker17Fixed coding standards.
Still to do: cleanly handle the case where there is no 'id' field.
Feedback welcome.
Comment #10
jmdeleon CreditAttribution: jmdeleon commentedPatch in #9 applied cleanly, continuing to evaluate it.
Comment #11
jmdeleon CreditAttribution: jmdeleon commentedStill looking at this one... would like to be able to cleanly handle the lack of an 'id' field before I commit this.
Comment #12
heddnThis fixed the issue for me. With a couple of us saying that, I think this is good to go.
Comment #14
jmdeleon CreditAttribution: jmdeleon commentedComment #15
jmdeleon CreditAttribution: jmdeleon commentedComment #16
ianstew41 CreditAttribution: ianstew41 commentedHI All
I was having some trouble but only just realised why. When I hit save to enable the highlight filter, it's status does not change to enabled. I.e. if I reload the page, it is still disabled. Anyone any idea what might cause that? I have changed my setup so that the _version_ field provides the ID.