Hi Typesense community :slightly_smiling_face: I ...
# community-help
t
Hi Typesense community šŸ™‚ I have been working with Natural Language Search query building and I discovered an interesting behavior with field ordering in
query_by
that I wanted to share and get your insights on. Issue: When searching for "fighting", I was getting 0 results despite having documents containing that exact word in the
title
field. Root Cause Found: The position of fields in the
query_by
parameter significantly affects search results. Here's what I discovered: āŒ This returned 0 results:
query_by:doc_id,doc_type,category_a,category_b,category_c,title,summary,description,tags,keywords,..."
āœ… This returned 1 result (correct):
query_by: "title,summary,description,tags,keywords,category_a,category_b,category_c,doc_id,doc_type,..."
Setup: • Using Typesense with Natural Language search (
nl_query: true
) • Collection has ~3,250 documentsSame query, same parameters, only
query_by
field order changed • Tested with
exhaustive_search: true
- didn't fix the issue Debug Evidence: With working field order,
text_match_info
shows:
Copy code
{
  "best_field_weight": 15,
  "fields_matched": 1,
  "best_field_score": "1108091338752"
}
Questions: 1. Is this expected behavior? Should field position in
query_by
affect whether matches are found at all? 2. Does Typesense have any internal logic that stops searching after early fields in the list? 3. Are there best practices for field ordering in
query_by
for optimal search results? 4. Could it be the case that if typesense doesn't get a result in the first few fields, it decides to give up? My queries had 16 fields in total. Solution Implemented: I reordered fields to put text-rich content fields first, categorical/ID fields last. This fixed the search completeness issue. Would love to understand the underlying mechanism better! Is this documented behavior or something worth investigating further?
a
Hey Tristan, Thank you for posting here! could you read this article and see if it helps? Feel free to add any questions here if it still doesn't make sense. https://typesense.org/docs/guide/faqs.html#keyword-search
āœ… 1
šŸ™ 1