Is it possible to search only on dexterity specific custom fields?

Hi,

Does anyone know if there's a way to make a search form on Plone with fields like "book title", "book author", "book year" and when the search runs, it will look for these information on the respective custom fields of a Dexterity content "book"?
Maybe using Faceted Navigation?

I guess the search of a term in a specific field can't be done. Just to be sure.

Thank you.

Hello Filipe,

Yes, it is possible. You will need to create new indexes on the Portal Catalog for it, but it should not be a big deal (take a look at https://training.plone.org/4/dexterity_2.html#add-catalog-indexes for examples)
Then Faceted Navigation would help filtering the content on listing and views.

Cheers,
ea

Thank you

1 Like

https://pypi.org/project/collective.collectionfilter/ is a good option for doing the search form. eea.facetnavigation is another option (after you add the custom indexes like erico suggested).

1 Like

Are you planning to 'just search for BookTitle' or is it important that you search only in the relevant fields?

For example, if you search for Hemingway as author you should not find books about him ?

The link is for the Plone 4 Training. The current version is https://training.plone.org/5/mastering-plone/dexterity_2.html#add-catalog-indexes

1 Like

The search has to be by field. Example: search all books by Hemingway. All published in 1970. All published by MacMillan.

And combination of Fields. Author x +year y, author x + has y in title, etc

catalog = plone.api.portal.get_tool('portal_catalog')
results = catalog(author="Hemingway", year=1960, searchable_title="some title")

Metadata with fixed values like years are easy to search. Performing fulltext searches on text is always a challenge and require some understanding of the sort of queries to be used and the technical understanding to figure your indexes properly...

The core problem with fulltext search in Plone is that the functionality is very limited and two decades behind what people expect from a fulltext search. Plone throws basically all content into a bag, handling title, description and body text equally. The general recommendation when you need a serious fulltext search in Plone: throw the build-in FT search away and replace with with Solr or Elasticsearch

I think you need to make a form or a viewlet yourself.

Faceted Navigation / Collectionfilter only does 'full text' search, if I remember right (so it will find no Hemingway or all )

Then you show the results as zopyx suggested.

If you use 'tick boxes' what you suggest is possible, like this: http://www.ektedata.no/no/innhold/oppgavebank#b_start=0

You could consider using javascript,

Sorry about that. DuckDuckGo pointed me to that page and I forgot to check :man_facepalming:

eea.facetednavigation with multiple select widget is all you need:

For author this is perfect, but it might be difficult to search for all titles that contains the word "Hemingway" without selecting them one by one (?)

In other words, if you want to find both "Bars of Hemingway" and "Fishing with Hemingway" (written by others)

not true for either plugin. Here is just one example of collectionfilter in use
https://www.mhcs.health.nsw.gov.au/publications. No custom code/viewlets is used here and it does use c.elasticsearch for better full text searching.

Either I am wrong or I misunderstood.

What I thought is that it is not possible to search for all authors that are named "Hemingway", you can only select them "one by one".
Or in your case, show any organization that contains "Austra", so "Australian Something" and "Something in Australia".

Is this possible?

You can use a ZCTextIndex in place of a field index in the catalog and then it will allow word matching or even partial word matching. Then you use a search field in collection filter instead of a dropdown.
It's even possible to have both a fieldindex and a textindex available for the same data, although it might be tricky without deploying custom code.
but I suspect you could do it by adding a python script that looks up the value by acquisition. e.g if the field is called is author then you can have a fieldindex with id author and also add another zctextindex with id author_text and create a python script in the root of your site with id author_text with "return context.author".

Plone Foundation Code of Conduct