# Error when using search ui and site search - map is undefined

**URL:** <https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786>\
**Category:** Elastic Search\
**Tags:** elastic-site-search\
**Created:** [July 10, 2019, 2:04pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786 "2019-07-10T14:04:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![elitzur\_e](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elitzur_e/32/48445_2.png) [@elitzur\_e](https://discuss.elastic.co/u/elitzur_e)\
**Post date:** [July 10, 2019, 2:04pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/1 "2019-07-10T14:04:32Z")

</div>

hi  
im using the latest search-ui (0.12) with the example code that works fine.  
when changing it to use the site search connector and updating the .env file (and some other small stuff to match it)  
i went on to remove all the facets etc. to have the minimum needed to have a search page. i used a search engine that already scanned one of my sites (apx. 2k pages)  
I get this error in the page:

**An unexpected error occurred: Cannot read property 'map' of undefined**

this is the app.js:  
[https://jsfiddle.net/viper123/7h1wx2vo/](https://jsfiddle.net/viper123/7h1wx2vo/)

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 10, 2019, 7:18pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/2 "2019-07-10T19:18:34Z")

</div>

> [@elitzur\_e](#):
>
> : Cannot read property 'map' of undefined

@elitzur_e I suspect this is a case of bad error messaging.

I was able to reproduce this bug by providing an invalid "documentType" credential. I suspect there is some server error occuring, likely related to one of the following 3 problems:

1. `engineKey` is invalid
2. `documentType` is invalid
3. There is no `title` field on your documents

In fact, it appears we have an issue in the project already to address this: [Bad error handling In the Site Search Connector · Issue #46 · elastic/search-ui · GitHub](https://github.com/elastic/search-ui/issues/46).

Will see about getting it fixed, in the meantime, see if you can inspect the raw API response in your browser and see if there is an error message available.

Also, the documentType should be "pages" .

---

<div class="post-metadata">

**Author:** ![elitzur\_e](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elitzur_e/32/48445_2.png) [@elitzur\_e](https://discuss.elastic.co/u/elitzur_e)\
**Post date:** [July 11, 2019, 5:35am UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/3 "2019-07-11T05:35:21Z")

</div>

Thanks. Ill try to change the docType.  
As for the response, There are search results returning in the response (network tab)

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 11, 2019, 12:12pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/4 "2019-07-11T12:12:30Z")

</div>

@elitzur_e Oh that's interesting. Hmmm, are you able to copy / paste the API response body so I can attempt to reproduce?

---

<div class="post-metadata">

**Author:** ![elitzur\_e](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elitzur_e/32/48445_2.png) [@elitzur\_e](https://discuss.elastic.co/u/elitzur_e)\
**Post date:** [July 11, 2019, 1:32pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/5 "2019-07-11T13:32:04Z")

</div>

its big. i added it here:  
[https://jsfiddle.net/viper123/o1kztwys/](https://jsfiddle.net/viper123/o1kztwys/)

---

<div class="post-metadata">

**Author:** ![elitzur\_e](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elitzur_e/32/48445_2.png) [@elitzur\_e](https://discuss.elastic.co/u/elitzur_e)\
**Post date:** [July 11, 2019, 1:49pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/6 "2019-07-11T13:49:17Z")

</div>

good news. got it to work. it was the documentType as you said. just "page" not "pages"

the error response could be better 🙂

i think the main confusion is from the example in this line:  
documentType: process.env.REACT\_SITE\_SEARCH\_ENGINE\_NAME  
so it seems that the engine name sould be there...  
thanks

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 11, 2019, 2:10pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/7 "2019-07-11T14:10:07Z")

</div>

@elitzur_e Oh great! Yeah, we will update that documentation. Sorry that you had so much trouble with this, definitely our bad. Let me know as your project progresses if I can be of any additional help.

For Search UI specific issues, feel free to drop an issue directly in the Github repository, or, we also have a gitter channel available for live chat: [https://gitter.im/elastic-search-ui/community](https://gitter.im/elastic-search-ui/community).

---

<div class="post-metadata">

**Author:** ![elitzur\_e](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elitzur_e/32/48445_2.png) [@elitzur\_e](https://discuss.elastic.co/u/elitzur_e)\
**Post date:** [July 11, 2019, 2:17pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/8 "2019-07-11T14:17:05Z")

</div>

thanks jsaon for the help. the fact the you try to help as much as possible says a good deal about the futrue of this product

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 8, 2019, 2:26pm UTC](https://discuss.elastic.co/t/error-when-using-search-ui-and-site-search-map-is-undefined/189786/9 "2019-08-08T14:26:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
