-
Notifications
You must be signed in to change notification settings - Fork 11
Define fields to search on at runtime #251
Define fields to search on at runtime #251
Conversation
🚨 Breaking API change detected: Modified (3)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add telemetry to know when a user is searching using attributesToSearchOn
?
|
||
- If `attributesToSearchOn` is not set or set to `null`, then the query will search on all `searchableAttributes`. | ||
- Sending the attributes in a different order than the order set in the settings `searchableAttributes` doesn't reorder the fields' rank for the `Attributes` ranking rule | ||
- 🔴 Sending a value with a different type than `Array of String`(POST), `String`(GET) or `null` for `attributesToSearchOn` returns an [invalid_attributes_to_search_on](0061-error-format-and-definitions.md#invalid_search_attributes_to_search_on) error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you send an empty array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that be specified or is it common practice in the API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that defining an empty attributesToSearchOn list means that you search in no attributes, which implies no results. Do you see any other behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not, I was just wondering if it might be surprising for a user to leave it empty and then be confused about getting no results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more on the side of the error if the array is sent with an empty form, so the developer can't break the search and is aware of it; By doing this, we can catch it before they have to understand what's wrong and fix it; I see no point in returning 0 results, am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could return the hits as if the query was empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more on the side of the error if the array is sent with an empty form, so the developer can't break the search and is aware of it; By doing this, we can catch it before they have to understand what's wrong and fix it; I see no point in returning 0 results, am I wrong?
I agree about the fact that would be useless to set []
, however, it's a logical behavior from Meilisearch in my sense. Moreover, it's consistent with the searchableAttributes
that accepts an empty array
Maybe we could return the hits as if the query was empty?
It doesn't seems logical to me to replace the search with a placeholder one when attributeToSearchOn
is empty. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right @ManyTheFish; accepting an empty array is an aspect of "consistency" that we could revisit with a v2 eventually because it doesn't seem great for DX (letting the developer put himself in a situation where he/she gets nothing out of the product)
I see it as an edge case personally, so the current implementation works for me, and I'm not against it
cc @macraig (if it helps!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 @gmourier , let's be consistent and revisit this when we're ready for a v2
Don't we want a telemetry point to see if the feature is used? |
@ManyTheFish how does |
3907: Add telemetry for define field to search on at query time r=dureuill a=ManyTheFish Add "attributes_to_search_on" telemetry usage counter: ```json "attributes_to_search_on": { "total_number_of_use": 12, }, ``` This measures the number of search queries that the user uses `attributesToSearchOn` field. related to meilisearch/specifications#251 ## reviewers: - `@macraig` for validating the telemetry's name - `@dureuill` for validating the code Co-authored-by: ManyTheFish <many@meilisearch.com>
Update telemetry
|
||
- If `attributesToSearchOn` is not set or set to `null`, then the query will search on all `searchableAttributes`. | ||
- Sending the attributes in a different order than the order set in the settings `searchableAttributes` doesn't reorder the fields' rank for the `Attributes` ranking rule | ||
- 🔴 Sending a value with a different type than `Array of String`(POST), `String`(GET) or `null` for `attributesToSearchOn` returns an [invalid_attributes_to_search_on](0061-error-format-and-definitions.md#invalid_search_attributes_to_search_on) error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right @ManyTheFish; accepting an empty array is an aspect of "consistency" that we could revisit with a v2 eventually because it doesn't seem great for DX (letting the developer put himself in a situation where he/she gets nothing out of the product)
I see it as an edge case personally, so the current implementation works for me, and I'm not against it
cc @macraig (if it helps!)
Summary
Update specifications related to the Define fields to search on at runtime feature.
Changes