Limiting or customising the content used for Algolia search? #7931
-
DescriptionI'm looking at ways to customise the search behaviour. I'm generally happy with the defaults, but I'd like to cut the terms of the search down to really just page titles. The reason is that our site has a bunch of dynamically generated pages that represent different places, and those pages have a lot of boilerplate text (I run a script before site render to generate the place pages). These are generated as:
Where each I don't really want to pollute the search with all of this boilerplate content; I'd really prefer to just be able to have the search happen on these page titles. I could also implement the search as an OJS control, but I'd really like to put the search in the site nav, so I'm hoping I can just modify the existing search functionality. I've been going through the current docs on this: The If I understand this correctly, how can I modify this to use nothing for the search text, and to only show the title? Or to use some other metadata field for the body? For example, if I added the root metadata key Alternatively (and this is the nuclear option), could I simply overwrite |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
Can confirm that replacing
_search.json
post-render works wonderfully! For example, writing out a JSON file like this:Gives you a search like this (obvs there's an extra entry in this screenshot):
And links correctly 😊