Automated summary in search results

I thought there was an existing plugin to do this but can't seem to find any.
Looking for either

  • using elasticsearch however collective.elasticsearch only seems to change the indexes, not metadata or search page. ideally to give a summary based on the search terms.
  • behaviour for dexterity which gives a sensible default for the summary when none exists, such as the first paragraph or 256 chars etc.

really no one has a solution for this?

No one has had someone ask for "can you automated the summary field?"

Hi @djay this is a usecase for custom index methods. There is an example in the documentation on how to achieve this: https://docs.plone.org/develop/plone/searching_and_indexing/indexing.html#custom-index-methods

you might look into collective.elasticindex which provides highlighted information about the search terms.

The latest fork-fork-fork is here

https://bitbucket.org/tgraf1981/collective.elasticindex

...it should work with Plone 4 but likely needs further love for Plone 5.

-aj

ok. I found one c2.search.customdescription ยท PyPI. But looks like it tries to customise the search page to change the summary based on the search. And its for plone 3 :frowning:

It's not actually a index issue. It's a metadata issue. ie what the search results display rather than what search for.

Ideally (if I don't go down the route of elasticsearch), what I want is that if someone leaves the Summary blank, then it automatically picks the first paragraph and/or first X chars instead. It would not display this on a Page but would display it for a File. For a folder... not sure, then it might have to look at the default page.

Looking at the code it looks like there is no quick hack to make this work without overriding the search results page. The Description method is used by both the Metadata and for displaying on the Page and File templates. The default implementation of this looks up self.description. I could monkey patch this but still the same method is used in both places, so either main_template or search has to change. Probably what is needed is an enhancement to the search results to call an adapter on each result which can override the summary generation. Then this could be implemented looking up a different metadata column which has the automated summary in or c.elasticindex could give something more relevant. But I think automated summaries is probably a good thing to have in the core to be honest.