Reputation: 584
I am currently working with the Algolia search API and I am unable to figure out how I would limit the results by key
value
searching + query string. By this i mean this.
I have a list of properties. Each property belongs to a client.
Within the application If i am looking at a client information card and I want to search for a property that client owns It would make more sense to limit the results to the client and then look for the query string.
I am using MongoDB as my DB and storing the client id as a sub document like so
//Property Document
{
_id : "randomID"
client : {
_id : "randomID",
name : "ClientName"
}
}
Upvotes: 3
Views: 637
Reputation: 2309
If you want to restrict the search to a specific client
, I would go for facet filtering to restrict the search to that client only.
client._id
in the attributesForFaceting
in your index settingsfacetFilters=client._id:MYCLIENTID
query parameterThen, you should also take a look at the Secured API keys which are able to encode such restriction in a secure way (so the end-user cannot patch the JS code and work-around the filtering).
Upvotes: 2
Reputation: 465
There is parameter called restrictSearchableAttributes
[link] to restrict, at query time, search to some attributes only. Nevertheless, in your case I think you'd get more accurate results by putting each client info
into a different record (+ the info of the related document).
Upvotes: 1