# Search Improvement

**URL:** <https://zola.discourse.group/t/search-improvement/344>\
**Category:** Feature requests\
**Created:** [March 4, 2020, 10:58am UTC](https://zola.discourse.group/t/search-improvement/344 "2020-03-04T10:58:26Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![SgtIria](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/sgtiria/32/85_2.png) [@SgtIria](https://zola.discourse.group/u/SgtIria)\
**Post date:** [July 24, 2020, 8:06pm UTC](https://zola.discourse.group/t/search-improvement/344/22 "2020-07-24T20:06:11Z")

</div>

Yes you have a number of options `defer` or `async`.

But the `elasticlunr` search engine will need to be initialised locally at some point and if the file is large it will be slow, the user may end up thinking that search does’nt work at all. We ended up accepting that the user will just have to have the file downloaded in the background once on the first page they hit, then rely on caching.

```auto
<script defer src="https://domain.com/a.js"></script>

```

- Scripts with `defer` never block the page.
- Scripts with `defer` always execute when the DOM is ready, but before `DOMContentLoaded` event.

```auto
<script async src="https://domain.com/a.js"></script>

```

- The page content shows up immediately: `async` doesn’t block it.
- `DOMContentLoaded` may happen both before and after `async` , no guarantees.
- Async scripts don’t wait for each other.

It can get complicated if you have dependencies in your scripts.

**Ultimately** deffering the ~~pain~~ cost of a large download does not solve the problem unless you don’t expect a user to use search. Obviously caching, gzip compression help.

You might be able to give a better first time impression of site performance.

Control over the size of the search index is the only way to go, if you have a page size (Kb budget) for a page (ours is a max of 1Mb) and about 800kb for critical pages. You can balance the search download costs with graphics and other media.

---

<div class="post-metadata">

**Author:** ![SgtIria](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/sgtiria/32/85_2.png) [@SgtIria](https://zola.discourse.group/u/SgtIria)\
**Post date:** [September 16, 2020, 9:59am UTC](https://zola.discourse.group/t/search-improvement/344/23 "2020-09-16T09:59:23Z")

</div>

> [@keats](#):
>
> Using the path instead of the permalink is a really good idea too.

## Zola 12 Still uses full path.

### Search\_index.en.js:

```auto
window.searchIndex = {"fields":["title","body"],"pipeline":["trimmer","stopWordFilter","stemmer"],"ref":"id","version":"0.9.5","index":{"body":{"root":{"docs":{},"df":0,"0":
{"docs":{"https://adeptenglish.com/lessons/english-learn-grammar-2/":{"tf":1.7320508075688772},
"https://adeptenglish.com/lessons/ielts-listening-practice-online/":{"tf":1.4142135623730951},

... 

```

As previously discussed, a significant improvement could be made if this was just the root path not the full site path.

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [September 16, 2020, 10:42am UTC](https://zola.discourse.group/t/search-improvement/344/24 "2020-09-16T10:42:34Z")

</div>

There were some potential issues with using path but I can’t remember right now ☹  
I think it might be ok for the search index

---

<div class="post-metadata">

**Author:** ![SgtIria](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/sgtiria/32/85_2.png) [@SgtIria](https://zola.discourse.group/u/SgtIria)\
**Post date:** [September 16, 2020, 10:43am UTC](https://zola.discourse.group/t/search-improvement/344/25 "2020-09-16T10:43:35Z")

</div>

Ok thanks for taking a look at it. Shame as it looked like an easy win. 🙂

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [September 16, 2020, 10:50am UTC](https://zola.discourse.group/t/search-improvement/344/26 "2020-09-16T10:50:08Z")

</div>

I’ll double check whether it was an issue with the search index or not, that is an easy win if possible.

---

<div class="post-metadata">

**Author:** ![SgtIria](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/sgtiria/32/85_2.png) [@SgtIria](https://zola.discourse.group/u/SgtIria)\
**Post date:** [September 22, 2020, 3:54pm UTC](https://zola.discourse.group/t/search-improvement/344/27 "2020-09-22T15:54:06Z")

</div>

# V12/13 Search

Other than the path optimization missing search is awesome. It’s everything we could have hoped for 🙂 **Thank you for implementing** this.

I might suggest that you mention there are now 3 fields available in the `search_index.en.js`

> title  
> description  
> content

It’s not really a zola issue as the search is mostly [elasticlunr](http://elasticlunr.com/) But for those who want to implement search mentioning that Zola generated three fields and that the JS implementation might want to `boost` (elasticlunr term..) these to specify importance placed on the field text the users search term was found.

Thinking about it, zola should just say the absolute minimum 🙂 or update the example used by getzola on github.

[Previous page](https://zola.discourse.group/t/search-improvement/344.md?page=1)
