Filtering by parameter
See original GitHub issueI have a backend in Laravel and rendering a vue-instantsearch
inside a blade
file.
@extends('layout._base')
@section('content')
<ais-index
app-id="{{ config('scout.algolia.id') }}"
api-key="{{ config('scout.algolia.public') }}"
index-name="patterns"
id="app"
query="{{ request('q') }}"
>
<div class="row">
<div class="col">
<ais-results>
<template slot-scope="{ result }">
<div class="card" v-if="@json(Auth::user()->id) == result.user_id">
<div class="card-header">
<a :href="result.path">
<ais-highlight :result="result" attribute-name="name"></ais-highlight>
</a>
</div>
<div class="card-body">
<ais-highlight :result="result" attribute-name="description"></ais-highlight>
</div>
</div>
<p>
</p>
</template>
</ais-results>
</div>
<div class="col-3">
<div class="card mb-5">
<div class="card-header font-weight-bold">Search</div>
<div class="card-body">
<ais-input placeholder="Search patterns..." class="form-control" :autofocus="true"></ais-input>
</div>
</div>
<div class="card">
<div class="card-header">
Filter By Category
</div>
<div class="card-body">
<ais-refinement-list attribute-name="category"></ais-refinement-list>
</div>
</div>
</div>
</div>
</ais-index>
@endsection
In line 15 I have a condition to match the user_id
with the current user logged in in the app. The condition is filtering properly but the downside of this is that…
- Everything is getting fetch from algolia regardless.
- Attributes for faceting are rendered with all fetched records so the faceting doesn’t match with records rendered.
Algolia data looks like this…
name: "Test"
brand: "Test Brand"
description: "This is an awesome description"
category: "accessories"
user_id: 3
objectID: "App\Pattern::17"
path: "patterns/17"
_tags: ["App\Pattern::17"]
I know that algolia has no knowledge of relationship whatsoever. I was hoping to filter the results by pushing the FK
but this approach is not optimal.
What other approaches I can take to accomplish this?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Filtering with parameters - Tableau
Parameters are extremely simple – they allow users to select or input a value. That value can then in turn be used in...
Read more >How to Filter with Parameter Actions in Tableau - Cleartelligence
How to Filter with Parameter Actions in Tableau · Click on Dashboard > Actions · Click "Add Action" · Select "Change Parameter" ·...
Read more >Filtering Parameters
The Data Filter options are divided by input and output parameters. Parameter information is displayed in the Data Filters tables near the bottom...
Read more >Using Parameter Actions to Filter in Tableau (with Multiple ...
Using Parameter Actions to Filter in Tableau (with Multiple Measures) · Step 1: Create a Parameter · Step 2: Create a Parameter Action...
Read more >Using filters with parameters in Amazon QuickSight
Use this section to filter the data in an analysis or dashboard by a single-value parameter value. To use a multivalued parameter—one with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@diazgilberto I had the same problem, I figured out that you have to add the attributes you want to filter on to the Index configuration on the Algolia website. In your Index, go to the “Configuration” tab, then “Facets” (even though we’re not using facets), and add the attributes you want to filter on in the “Attributes for faceting” zone and select “Filter only” for these attributes. This is how I ended solving this problem.
Hope this helps!
@Haroenv the app is minimal already. The data is toy data and the app is fairly small. Interestingly, with the
filters: user_id: ...
parameter passed to theXHR
request I’m not getting any data back.Here are the
patterns
data in algoliaHere the
patterns
data in my databaseand I’m logged in with
user_id
1.the
blade.php
filethe
XHR
requestAs you can see, the
filters: user_id: 1
is getting passed in the request.