#community-help

Issue With Expanded 'query_by' Fields in Typesense search

TLDR Emma experienced fewer search results with more 'query_by' fields in Typesense. Kishore Nallan explained that matching can vary with more fields, but didn't offer a solution.

Powered by Struct AI
Sep 21, 2023 (2 months ago)
Emma
Photo of md5-01ff2c7cb764a071332074d6e85db0c5
Emma
06:57 AM
Is there any reason why adding more fields in query_by would… give fewer results? When I search for fate zero in my index with query_by=canonical_title I get the expected result (the anime where canonical_title: "Fate/zero") but if I do query_by=canonical_title,titles.*,alternative_titles,descriptions.*&query_by_weights=100,90,90,80 then I stop getting that result and instead get a weird match (an anime where canonical_title: "Gravitation")

This is the match info for query_by=canonical_title,titles.*……………… (incorrect result):
      "text_match_info": {
        "best_field_score": "1112386306048",
        "best_field_weight": 13,
        "fields_matched": 1,
        "score": "1155199671761633385",
        "tokens_matched": 2
      }

vs for the query_by=canonical_title (correct result):
      "text_match_info": {
        "best_field_score": "1108091339008",
        "best_field_weight": 15,
        "fields_matched": 1,
        "score": "578730123365711993",
        "tokens_matched": 1
      }

My initial theory is the / is throwing it off, but I’m not sure, I would assume / is considered a word separator
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:02 AM
When multiple documents match a given token (e.g. in case of typo matching or prefix search), Typesense chooses best matched candidates. When you add more fields the actual word that's resolved can vary and so that can produce more or less docs.b