-
Notifications
You must be signed in to change notification settings - Fork 11
Define fields to search on at runtime #251
Changes from 8 commits
f5db7b6
705121c
6d22d58
97cea19
8bf29c6
eba4c93
12211c7
0f97847
015cfd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ If a master key is used to secure a Meilisearch instance, the auth layer returns | |
| | [`cropMarker`](#3115-cropmarker) | String | False | | ||
| | [`showMatchesPosition`](#3116-showmatchesposition) | Boolean | False | | ||
| | [`matchingStrategy`](#3117-matchingStrategy) | String | False | | ||
| | [`attributesToSearchOn`](#3118-attributesToSearchOn) | Array of String - String | False | | ||
|
|
||
|
|
||
| #### 3.1.1. `q` | ||
|
|
@@ -912,6 +913,20 @@ The documents containing ALL the query words (i.e. in the `q` parameter) are ret | |
|
|
||
| Only the documents containing ALL the query words (i.e. in the `q` parameter) are returned by Meilisearch. If Meilisearch doesn't have enough documents to fit the requested `limit`, it returns the documents found without trying to match more documents. | ||
|
|
||
| #### 3.1.17. `attributesToSearchOn` | ||
|
|
||
| - Type: Array of String (POST) | String (GET) | ||
| - Required: False | ||
| - Default: `["*"]` | ||
|
|
||
| Defines which `searchableAttributes` the query will search on. | ||
|
|
||
| - If `attributesToSearchOn` is not set, set to `["*"]` 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if you send an empty array?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty result
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should that be specified or is it common practice in the API?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could return the hits as if the query was empty?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree about the fact that would be useless to set
It doesn't seems logical to me to replace the search with a placeholder one when
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| - 🔴 Sending an attribute that is not part of the settings `searchableAttributes` list returns an [invalid_attributes_to_search_on](0061-error-format-and-definitions.md#invalid_search_attributes_to_search_on) error. | ||
|
|
||
|
|
||
| ### 3.2. Search Response Properties | ||
|
|
||
| | Field | Type | Required | | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.