Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete returning empty result #1201

Closed
1 task done
Prottoy2938 opened this issue Oct 6, 2023 · 1 comment
Closed
1 task done

Autocomplete returning empty result #1201

Prottoy2938 opened this issue Oct 6, 2023 · 1 comment

Comments

@Prottoy2938
Copy link

🐛 Current behavior

I’m following this autocomplete sandbox demos from Algolia to setup autocomplete on our startup landing page @hwdoi.com. I’ve added all the configration properly, but not search suggestions are showing up.

This is the structure of my records:


{
"title": "Liphello tsa Matsatsi a Tšebeletso a fosahetseng ke afe?",
"blogTitle": "How to Calculate Date of Service?",
"blogTitleEn": "Mokhoa oa ho Bala Letsatsi la Tšebeletso?",
"langCode": "st",
"url": "general/how-to-calculate-date-of-service#liphello-tsa-matsatsi-a-tšebeletso-a-fosahetseng-ke-afe-what-are-the-consequences-of-incorrect-dates-of-service-in-sesotho",
"section": "general",
"objectID": "fffac6cb-617c-4eb5-a127-4bba9dc1f687"
}

& this is frontend my code (following the demo codesandbox code):

import { autocomplete, getAlgoliaResults } from '@algolia/autocomplete-js';
import algoliasearch from 'algoliasearch';

import '@algolia/autocomplete-theme-classic';


const searchClient = algoliasearch(
'074EKL3K2D',
'4ed78f0ba59d4b5cbc289722dcf9a4ff'
);



autocomplete({
container: '#autocomplete',
placeholder: 'Search for products',
insights: true,
getSources({ query }) {
return [
{
sourceId: 'products',
getItems() {
return getAlgoliaResults({
searchClient,
queries: [
{
indexName: 'instant_search',
query,
params: {
hitsPerPage: 5,
attributesToSnippet: ['name:10', 'description:35'],
snippetEllipsisText: '…',
},
},
],
});
},
templates: {
item({ item, components, html }) {
return html`<div class="aa-ItemWrapper">
<div class="aa-ItemContent">
<div class="aa-ItemIcon aa-ItemIcon--alignTop">
<img
src="${item.image}"
alt="${item.name}"
width="40"
height="40"
/>
</div>
<div class="aa-ItemContentBody">
<div class="aa-ItemContentTitle">
${components.Highlight({
hit: item,
attribute: 'name',
})}
</div>
<div class="aa-ItemContentDescription">
${components.Snippet({
hit: item,
attribute: 'description',
})}
</div>
</div>
<div class="aa-ItemActions">
<button
class="aa-ItemActionButton aa-DesktopOnly aa-ActiveOnly"
type="button"
title="Select"
>
<svg
viewBox="0 0 24 24"
width="20"
height="20"
fill="currentColor"
>
<path
d="M18.984 6.984h2.016v6h-15.188l3.609 3.609-1.406 1.406-6-6 6-6 1.406 1.406-3.609 3.609h13.172v-4.031z"
/>
</svg>
</button>
<button
class="aa-ItemActionButton"
type="button"
title="Add to cart"
>
<svg
viewBox="0 0 24 24"
width="18"
height="18"
fill="currentColor"
>
<path
d="M19 5h-14l1.5-2h11zM21.794 5.392l-2.994-3.992c-0.196-0.261-0.494-0.399-0.8-0.4h-12c-0.326 0-0.616 0.156-0.8 0.4l-2.994 3.992c-0.043 0.056-0.081 0.117-0.111 0.182-0.065 0.137-0.096 0.283-0.095 0.426v14c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h14c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-14c0-0.219-0.071-0.422-0.189-0.585-0.004-0.005-0.007-0.010-0.011-0.015zM4 7h16v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-14c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707zM15 10c0 0.829-0.335 1.577-0.879 2.121s-1.292 0.879-2.121 0.879-1.577-0.335-2.121-0.879-0.879-1.292-0.879-2.121c0-0.552-0.448-1-1-1s-1 0.448-1 1c0 1.38 0.561 2.632 1.464 3.536s2.156 1.464 3.536 1.464 2.632-0.561 3.536-1.464 1.464-2.156 1.464-3.536c0-0.552-0.448-1-1-1s-1 0.448-1 1z"
/>
</svg>
</button>
</div>
</div>
</div>`;
},
},
},
];
},
});

Also, When I’m in the Algolia dashboard, I can see the search suggestions on my test4 index.

Any help? Our website is fully stuck right now because of it.

🔍 Steps to reproduce

  1. Copy my code/my index, apiKey & appID

Live reproduction

https://codesandbox.io/s/github/algolia/autocomplete/tree/next/examples/query-suggestions?file=/app.tsx

💭 Expected behavior

Should show search suggestions

Package version

4.20.0

Operating system

Windows 10

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Haroenv
Copy link
Contributor

Haroenv commented Oct 9, 2023

I see in the code you're using instant_search as the index name, is that actually the index name?

@Haroenv Haroenv transferred this issue from algolia/instantsearch Oct 9, 2023
@algolia algolia locked and limited conversation to collaborators Oct 9, 2023
@Haroenv Haroenv converted this issue into discussion #1202 Oct 9, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants