typesense / typesense

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Home Page:https://typesense.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG - Typesense does not considers "query_by_weights" when equal weightage is same

BekaArabidze98 opened this issue · comments

commented

Description

Hello.
I have couple of queryFields likes this -> const queryFields = ['name', 'description', 'request', 'responses', 'dataExample', 'endpoints'];

  const weights = new Array(queryFields.length).fill(1).join(',');

const filter = {
    q: query,
    query_by: `${queryFields.join(',')}`,
    per_page: '20',
    text_match_type: 'max_weight',
    query_by_weights: weights,
    prioritize_exact_match: false,
    // split_join_tokens: 'always',
    // exhaustive_search: true,
    page,
  };
  
const schema = {
  name: 'collections',
  enable_nested_fields: true,
  fields: [
    { name: 'id', type: 'string', facet: false },
    { name: 'documentId', type: 'string', facet: false },
    { name: 'name', type: 'string', facet: false, infix: true },
    { name: 'description', type: 'string', facet: true, infix: true },
    { name: 'request', type: 'auto', facet: false, infix: true },
    { name: 'responses', type: 'auto', facet: false, infix: true, optional: true },
    { name: 'dataExample', type: 'auto', facet: false, infix: true, optional: true },
    { name: 'endpoints', type: 'auto', facet: false, infix: true, optional: true },
    { name: 'createdAt', type: 'string', facet: false, sort: true },
  ],
  token_separators: [
    '@',
    '_',
    '-',
    '.',
    '{',
    '}',
    '/',
    '&',
    '?',
    '=',
    '!',
    '(',
    ')',
    '+',
    ':',
    ',',
  ],
  default_sorting_field: 'createdAt',
};

when I search for something that is related to endpoints, typesense does not return correct record.
But If I move endpoints to, for example, on the second or third place then, It returns correct result.
I have large collection of nested data and maybe that's why this happens, but not sure.
query_by_weights - It is all 1 to have same equal weightage

I tried to use exhaustive_search option but It completely crashes server

Actual Behavior

I am expecting to return both results, despite where my endpoint query field in array

Actual Behavior

Example - I have two similar endpoints in my docs like this - /ConsentTypes/{clientId} and /ConsentTypes/{clientId}?Id=
If endpoints field is last then only first result is shown, and If I move endpoint then both shown.

Metadata

Typesense Version: 0.24.1