Skip to content

Minisearch doesn't return the exact match for title for some objects in the search index #291

Open
@pavinduLakshan

Description

@pavinduLakshan

i have this json obj in my search index.

{"location":"references/app-settings/oidc-settings-for-app/#access-token-attributes","title":"Access Token Attributes","text":"

For JWT access tokens, this feature enables you to specify which user attributes are included in the access token. As a result, when a user logs in to an application, only the chosen attributes are shared, providing enhanced security and flexibility.

Note

All configured user attributes are included in the access token, regardless of the requested scopes.

"},

i search for this using the term "access token attributes" using minisearch, but it doesn't return this result. any idea why?

FYI, this is how i use minisearch in my project.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/index.min.js"></script>

<script>
  let miniSearch; // Declare globally

  (async function () {
    const docsBasePath = "http://localhost:8000/docs/";
    const searchIndexPath = docsBasePath + "search/search_index.json";

    const docResponse = await fetch(searchIndexPath);
    const documents = await docResponse.json();

    // Initialize MiniSearch in the global scope
    miniSearch = new MiniSearch({
      fields: ['title', 'text'],
      idField: 'title',
      storeFields: ['title', 'text'],
      limit: 100,
      prefix: true,
      searchOptions: {
        boost: { title: 2, text: 1 },
        fuzzy: 0.2
      }
    });

    miniSearch.addAll(documents.docs);
  })();

  function search(query) {
    if (!miniSearch) {
      console.warn("Search is not ready yet.");
      return;
    }
    let results = miniSearch.search(query);
    console.log(results);
  }
</script>

<input type="text" style="color: black;" 
  placeholder="Search..." 
  oninput="search(this.value)">

Appreciate any type of help/sugggestions. thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions