Building search index with title and description only

Hello there!
I’m newbie in Zola, and first, many thanks Vincent and other for the cool engine. It’s awesome!

I have a small question about search index building. If you have 1000 pages it’s would be nightmare to get all texts in search file, might zola or lunr have any mechanism to limit search index with titles and descriptions only?

Thank you!

No way to do that currently no :slightly_frowning_face:

If you really have thousands of pages, it’s probably better to not have your search be done in JS like that anyway as the results are not going to be great when based only on name/description. The JS index might get pretty big as well. The Zola docs site for example is pretty small but the index is already 600kb

1 Like

I can’t test it, but what if I change in components/search/src/lib.rs string

let mut index = Index::with_language(language, &[“title”, “body”]);

to

let mut index = Index::with_language(language, &[“title”, “description”]);

'cause poor search better than no search :slight_smile:

for future searchers it didn’t work :slight_smile:

What was the issue?

Search index had the same size anyway, but search works on titles only. Maybe I missed something, and it needs to be fixed somewhere else

Did you update the JavaScript to edit the elasticlunr options? By default it uses the keys title & body, you probably need to set description instead of body.

unfortunately, it’s not about JS, I got search index with full content but the string named “description”

Bu I’ll try to create “title only” index, maybe it works