I need help with algolia numeric filters

Hey I am using numeric filters to filter out data based on visibility.

@if(\Illuminate\Support\Facades\Auth::check())
    @if(\Illuminate\Support\Facades\Auth::user()->role==1) <!--Dealer -->
        <ais-index
                app-id="Q5IYJ43XF9"
                api-key="eb9bda691044aed1d217db64608643dc"
                index-name="phones"
                :query-parameters="{
                     numericFilters:['sold != 1'],
                     numericFilters:'(visibility = 3,visibility = 2)'
                   }"
        >
        @elseif(\Illuminate\Support\Facades\Auth::user()->role==2) <!--User -->
            <ais-index
                    app-id="Q5IYJ43XF9"
                    api-key="eb9bda691044aed1d217db64608643dc"
                    index-name="phones"
                    :query-parameters="{
                     numericFilters:['sold != 1'],
                     numericFilters:'(visibility = 3,visibility = 1)'
                   }"
            >
     @endif
 @else
                    <ais-index
                            app-id="Q5IYJ43XF9"
                            api-key="eb9bda691044aed1d217db64608643dc"
                            index-name="phones"
                            :query-parameters="{
                     numericFilters:['sold != 1'],

                   }"
                    >
 @endif

now I am able to get data where visibility is 3 or 2 or 1 but data with visibility “3”, “2”, “1” cannot be withdrawn. Can you please help as I am new and I dont know what I might be missing?

Hey there,

Just to understand your question properly; are you saying that you want a numeric filter with a string of a number, with the quotes included? As in: "1" instead of 1?

Unfortunately that won’t be possible now, you need to make sure that when you’re indexing, you’re indexing as a number if that’s what you need to use.

I hope that helped!

Hey @haroen This is the code I am using for indexing as a number. I dont know but it always indexes it as a string

public function store(UploadPhoneRequest $request){
        $data=$request->except(['company']);
        $data['data_id']=$data['model'];
        unset($data['model']);
        $phone=Auth::user()->phones()->create($data);

        $phone->conditions()->attach($request->input('conditions'));

        $phone->accessories()->attach($request->input('accessories'));

        foreach ($request->photos as $photo) {
            $filename = $photo->store('photos');
            $image = Image::make(Storage::get($filename))->resize(470,352.5)->insert(public_path('images/TRAWAL.png'), 'bottom-right', 10, 10)->encode();
            Storage::put($filename, $image);

            Photo::create([
                'phone_id' => $phone->id,
                'filename' => $filename
            ]);
        }
        $phone->update(['dp'=>$phone->photos->first()->filename]);
        if($data['visibility']==3)
            $phone->update(['visibility'=>3]);
        else if($data['visibility']==2)
            $phone->update(['visibility'=>2]);
        else
            $phone->update(['visibility'=>1]);
        \request()->session()->flash('status', 'Successfully Added Listing!');
        return redirect()->route('phones.show');
    }

You should cast it as an int like this: (int)$phone->id or wherever you’re actually uploading (I can’t tell from this code snippet which data actually gets pushed to Algolia)