Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display ellipsis before and after fragment in SOLR

I have SOLR configured to return fragments with a fragsize of 500.

Sometimes, the whole field is 500 characters or less, so the fragment is identical to the field. For fields that are longer than that, SOLR just returns the fragment without any indication (or so it seems) that the fragment only represents part of the content of a field. That means the fragment could start mid-sentence.

I want to make it clear to users that they're looking at a fragment and simply display ellipsis at the end and/or start of such a fragment. Is that functionality built into SOLR? If not, how would you go about inserting ellipsis?

like image 479
Stefan Avatar asked Aug 03 '10 19:08

Stefan


1 Answers

What I ended up doing was returning both the fragment and the unaltered field from which the fragment was created.

I then wrote some logic that compared the two in order to determine whether ellipsis should be added to the fragment and if so, whether to add it before, after or both before and after the fragment.

like image 55
Stefan Avatar answered Sep 20 '22 18:09

Stefan