Reputation: 3724
I see in the documentation for restrictSearchableAttributes that I can restrict a query to specific attributes, and that works fine.
However, I'd like to be able to restrict just a part of the query to that attribute the way you can with Gmail's search functionality.
For example, I want the user to be able to search for:
Travel from:John
And that would look for the word "John" only in the "from" attribute, and then it would also look for Travel across all searchable attributes.
I could make from
a facet, and send Travel
as the query and then facetFilters[from:John]
but if the from
value is "John Smith" it won't be a hit. Facets have to be perfect matches.
I would appreciate any help on this and am happy to provide more clarification where necessary.
Upvotes: 2
Views: 461
Reputation: 12042
What you could do would be to create an index containing your users. When the input contains a trigger string (like "from:"), you could have an autocomplete search into these and then add them to the final query as facet.
An example of an use-case pretty similar can be found in the Autocomplete In a Textarea which is implementing a twitter-like mention system.
Mixing this with a regular query you'd have done otherwise could be a fit.
Upvotes: 1