# Lunr js not giving results

**URL:** <https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466>\
**Category:** Help\
**Created:** [February 9, 2018, 7:19am UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466 "2018-02-09T07:19:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 9, 2018, 7:19am UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/1 "2018-02-09T07:19:11Z")

</div>

Please check this site [https://bpmottathai.gitlab.io/test/search2](https://bpmottathai.gitlab.io/test/search2)

I configures the site according to [https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/](https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/)  
But results is not showing

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 19, 2018, 3:59pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/2 "2018-02-19T15:59:20Z")

</div>

Any help please, I tried with github version it worked. But on gitlab it doesn’t worked…

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [February 19, 2018, 4:49pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/3 "2018-02-19T16:49:13Z")

</div>

Can’t speak for why it works on GitHub and not GitLab, but if you check the browser’s console you’re getting the following JavaScript errros:

```auto
search.js:36 Uncaught TypeError: Cannot read property 'setAttribute' of null
    at search.js:36
    at search.js:61
(anonymous) @ search.js:36
(anonymous) @ search.js:61

```

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 20, 2018, 5:29am UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/4 "2018-02-20T05:29:11Z")

</div>

Hi @mmistakes Thanks for responding. I am a newbie here. Where can be the problem?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [February 20, 2018, 5:19pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/5 "2018-02-20T17:19:29Z")

</div>

what is the content of your `.gitlab-ci.yml` file on gitlab? if it works on GH but not GL there is probably something missing from your build file. Like maybe you are just building the site rather than bundle whatever (I don’t use bundler so I don’t remember what all you have to run to get it to check your plugins and install them as needed).

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 20, 2018, 5:56pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/6 "2018-02-20T17:56:20Z")

</div>

```
image: ruby:2.3

variables:
  JEKYLL_ENV: production

before_script:
  - export LC_ALL="C.UTF-8"
  - export LANG="en_US.UTF-8"
  - export LANGUAGE="en_US.UTF-8"
  - bundle install

test:
  stage: test
  script:
  - bundle exec jekyll build -d test
  artifacts:
    paths:
    - test
  except:
  - master

pages:
  stage: deploy
  script:
  - bundle exec jekyll build -d public
  artifacts:
    paths:
    - public
  only:
  - master

```

It also not works in localhost…

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [February 20, 2018, 7:15pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/7 "2018-02-20T19:15:26Z")

</div>

have you checked the logs to see if there were any errors?

I would maybe add the `bundle install` line to the pages section right before bundle exec? no idea if that would help though, I have one site on GL and battled quite a bit to get it to all work the way I wanted but that didn’t have anything to do with bundler.

can you post a link to the working GH site? maybe there is a difference in a path to the js files or something.

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 20, 2018, 7:25pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/8 "2018-02-20T19:25:15Z")

</div>

> **[Search](http://pharmacy.justinechacko.in/search2/?query=triazole)**
>
> Search

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [February 20, 2018, 8:09pm UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/9 "2018-02-20T20:09:52Z")

</div>

I’m not a JavaScript expert but could it be because the search box in the header and on the page both have the same ID selector? Looks like its failing on getting the `query` from the search input.

Entirely possible it’s getting confused because you have two `input` elements named the same thing.

```javascript
document.getElementById('search-box').setAttribute("value", searchTerm);

```

As a test maybe try changing the header box to something else and keep the input on the page `search-box`.

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 21, 2018, 3:53am UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/10 "2018-02-21T03:53:25Z")

</div>

Still it doesn’t work

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [February 21, 2018, 4:51am UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/11 "2018-02-21T04:51:47Z")

</div>

wild guess - on the site that doesn’t work you are loading search.js in the head - I think you need to load it last so move that line `<script src="/test/bs/assets/javascripts/search.js"></script>` to the footer some where.

On the site where it does work you have a really screwy document that sort of looks like an html page inside another html page - I am surprised any of it works, but I think the search works as it is loaded in the second head section and I think that is after something else loads that it needs.

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [February 21, 2018, 11:43am UTC](https://talk.jekyllrb.com/t/lunr-js-not-giving-results/1466/12 "2018-02-21T11:43:01Z")

</div>

Thanks @rdyar That solved the probem. I changed the js line to footer.
