-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define field to search on at search-time #3772
Comments
Hello @ManyTheFish 👋 Seeing how the PR is already open for this feature, I hope I'm not arriving too late to the party 😃 I have feedback regarding this feature, in light of a discussion I had with @LukasKalbertodt
(I'm quoting them) So, I think it would be great if the "Define field to search on at search-time" could take this need into account, either in this first cycle if attainable at all, or at least planned as a future extension. Concretely, the changes it would entail IMO:
Thanks for reading, Side note:
What is the rationale for returning an "empty response" in that case? I would expect either:
|
Hello @dureuill,
Well, it's not really the case, Meilisearch behaves as you explained in (2)
We can do this 😄 we only chose
I personally don't like the weight approach, it's too tricky to set a good weight for a field from the end-user perspective. Moreover, it would be inconsistent with the setting API that defines an order.
It's completely doable, but I feel that is something different that the planned feature for v1.3. |
Thank you ManyTheFish for the detailed answer
Ah OK, this happens in the case where If I have to choose between this particular edge case and fixing the typos I prefer we fix the typos. Maybe this is inconsistent with some other attributes related APIs usable at search time, though? We would need to check that. I'm noting that our competitors only allow About the naming change and scope change, I think it would be best if we discussed this synchronously. To be clear I'm not suggesting we completely remove the possibility to specify a list of attributes, just advocating that we add the additional capability of specifying the weights. In an ideal world we would also upgrade the setting to accept the weights additionally to the list. |
3834: Define searchable fields at runtime r=Kerollmops a=ManyTheFish ## Summary This feature allows the end-user to search in one or multiple attributes using the search parameter `attributesToSearchOn`: ```json { "q": "Captain Marvel", "attributesToSearchOn": ["title"] } ``` This feature act like a filter, forcing Meilisearch to only return the documents containing the requested words in the attributes-to-search-on. Note that, with the matching strategy `last`, Meilisearch will only ensure that the first word is in the attributes-to-search-on, but, the retrieved documents will be ordered taking into account the word contained in the attributes-to-search-on. ## Trying the prototype A dedicated docker image has been released for this feature: #### last prototype version: ```bash docker pull getmeili/meilisearch:prototype-define-searchable-fields-at-search-time-1 ``` #### others prototype versions: ```bash docker pull getmeili/meilisearch:prototype-define-searchable-fields-at-search-time-0 ``` ## Technical Detail The attributes-to-search-on list is given to the search context, then, the search context uses the `fid_word_docids`database using only the allowed field ids instead of the global `word_docids` database. This is the same for the prefix databases. The database cache is updated with the merged values, meaning that the union of the field-id-database values is only made if the requested key is missing from the cache. ### Relevancy limits Almost all ranking rules behave as expected when ordering the documents. Only `proximity` could miss-order documents if all the searched words are in the restricted attribute but a better proximity is found in an ignored attribute in a document that should be ranked lower. I put below a failing test showing it: ```rust #[actix_rt::test] async fn proximity_ranking_rule_order() { let server = Server::new().await; let index = index_with_documents( &server, &json!([ { "title": "Captain super mega cool. A Marvel story", // Perfect distance between words in an ignored attribute "desc": "Captain Marvel", "id": "1", }, { "title": "Captain America from Marvel", "desc": "a Shazam ersatz", "id": "2", }]), ) .await; // Document 2 should appear before document 1. index .search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["title"], "attributesToRetrieve": ["id"]}), |response, code| { assert_eq!(code, 200, "{}", response); assert_eq!( response["hits"], json!([ {"id": "2"}, {"id": "1"}, ]) ); }) .await; } ``` Fixing this would force us to create a `fid_word_pair_proximity_docids` and a `fid_word_prefix_pair_proximity_docids` databases which may multiply the keys of `word_pair_proximity_docids` and `word_prefix_pair_proximity_docids` by the number of attributes in the searchable_attributes list. If we think we should fix this test, I'll suggest doing it in another PR. ## Related Fixes #3772 Co-authored-by: Tamo <tamo@meilisearch.com> Co-authored-by: ManyTheFish <many@meilisearch.com>
3876: Fix invalid attributeToSearchOn error code r=Kerollmops a=ManyTheFish Fix the invalid attributeToSearchOn error code to be consistent with the other search parameters' error codes: error code `invalid_attributes_to_search_on` becomes `invalid_search_attributes_to_search_on`: ```diff - invalid_attributes_to_search_on + invalid_search_attributes_to_search_on ``` related to #3772 Co-authored-by: ManyTheFish <many@meilisearch.com>
Hello everyone 👋 We have just released the first RC (release candidate) of Meilisearch containing this change! docker run -it --rm -p 7700:7700 -v $(pwd)/meili_data:/meili_data getmeili/meilisearch:v1.3.0-rc.0 If you encounter any bugs, please report them here. 🎉 The official and stable release containing this change will be available on July 31st, 2023 |
Related product team resources: roadmap card (internal only)
Related product discussions:
Related spec: WIP
Motivation
Both Algolia and Typesense support this feature and it has been flagged several times as a blocker to adoption.
Usage
Enables running searches over a subset of searchableAttributes without modifying Meilisearch’s index settings.
TODO
main
Technical prototype's TODO (@ManyTheFish addition)
restrictSearchableAttributes
)All
must only return documents containing all the requested words in the searched fieldx
in the searched field must be ranked before a document containing query-words with a perfect distance in another field but a distancey
worse thanx
in the searched field.Remaining Uncertainties (@ManyTheFish addition) (poke @macraig)
After making a technical tour of the feature, some uncertainties remain:
API
: The dedicated search parameter is not defined, here is the comment link showing some competitor APIsrestrictSearchableAttributes
Undefined behavior
: when the end user search in a field that is not part of the searchable attribute the behavior of Meilisearch is undefined, we could return an error or return an empty responseExpectations of the feature
: Does the order of the field given at search time reorder the searchable attribute order given in the settingsExpectations of the feature
, the feature could be implemented as an exclusive filter ("I only want the documents matching in this field") or as a ranking priority ("I want the documents matching in this field to be ranked before the others")Impacted teams
@meilisearch/docs-team @meilisearch/integration-team
The text was updated successfully, but these errors were encountered: