Tristan Bagnulo
09/26/2025, 5:49 PMquery_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:
{
"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?Alan Martini
09/26/2025, 5:51 PM